From 0dc15eb64ac268e115c484319941ba11ce09d596 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 16 Sep 2016 11:14:49 -0700 Subject: [PATCH] fix(ContentChild): query descendants by default fixes #1645 --- modules/@angular/core/src/metadata/di.ts | 2 +- .../core/test/linker/query_integration_spec.ts | 11 +++++++++++ tools/public_api_guard/core/testing/index.d.ts | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/@angular/core/src/metadata/di.ts b/modules/@angular/core/src/metadata/di.ts index c50e3b2f54..0622034b16 100644 --- a/modules/@angular/core/src/metadata/di.ts +++ b/modules/@angular/core/src/metadata/di.ts @@ -275,7 +275,7 @@ export const ContentChild: ContentChildDecorator = makePropDecorator( ['selector', undefined], { first: true, isViewQuery: false, - descendants: false, + descendants: true, read: undefined, } ], diff --git a/modules/@angular/core/test/linker/query_integration_spec.ts b/modules/@angular/core/test/linker/query_integration_spec.ts index 9bb7cea7ed..8d024cdc20 100644 --- a/modules/@angular/core/test/linker/query_integration_spec.ts +++ b/modules/@angular/core/test/linker/query_integration_spec.ts @@ -250,6 +250,17 @@ export function main() { expect(comp.textDirChild.text).toEqual('ca'); }); + it('should contain the first descendant content child', () => { + const template = '' + + '
' + + '
'; + const view = createTestCmpAndDetectChanges(MyComp0, template); + + const comp: NeedsContentChildWithRead = + view.debugElement.children[0].injector.get(NeedsContentChildWithRead); + expect(comp.textDirChild.text).toEqual('ca'); + }); + it('should contain the first view child', () => { const template = ''; const view = createTestCmpAndDetectChanges(MyComp0, template); diff --git a/tools/public_api_guard/core/testing/index.d.ts b/tools/public_api_guard/core/testing/index.d.ts index b0abcba28d..48d5255583 100644 --- a/tools/public_api_guard/core/testing/index.d.ts +++ b/tools/public_api_guard/core/testing/index.d.ts @@ -20,10 +20,10 @@ export declare class ComponentFixture { } /** @experimental */ -export declare var ComponentFixtureAutoDetect: OpaqueToken; +export declare const ComponentFixtureAutoDetect: OpaqueToken; /** @experimental */ -export declare var ComponentFixtureNoNgZone: OpaqueToken; +export declare const ComponentFixtureNoNgZone: OpaqueToken; /** @experimental */ export declare function discardPeriodicTasks(): void;