Skip to content

Commit 0dc15eb

Browse files
vicbalexeagle
authored andcommitted
fix(ContentChild): query descendants by default
fixes #1645
1 parent cba885a commit 0dc15eb

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

modules/@angular/core/src/metadata/di.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export const ContentChild: ContentChildDecorator = makePropDecorator(
275275
['selector', undefined], {
276276
first: true,
277277
isViewQuery: false,
278-
descendants: false,
278+
descendants: true,
279279
read: undefined,
280280
}
281281
],

modules/@angular/core/test/linker/query_integration_spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ export function main() {
250250
expect(comp.textDirChild.text).toEqual('ca');
251251
});
252252

253+
it('should contain the first descendant content child', () => {
254+
const template = '<needs-content-child-read>' +
255+
'<div dir><div #q text="ca"></div></div>' +
256+
'</needs-content-child-read>';
257+
const view = createTestCmpAndDetectChanges(MyComp0, template);
258+
259+
const comp: NeedsContentChildWithRead =
260+
view.debugElement.children[0].injector.get(NeedsContentChildWithRead);
261+
expect(comp.textDirChild.text).toEqual('ca');
262+
});
263+
253264
it('should contain the first view child', () => {
254265
const template = '<needs-view-child-read></needs-view-child-read>';
255266
const view = createTestCmpAndDetectChanges(MyComp0, template);

tools/public_api_guard/core/testing/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export declare class ComponentFixture<T> {
2020
}
2121

2222
/** @experimental */
23-
export declare var ComponentFixtureAutoDetect: OpaqueToken;
23+
export declare const ComponentFixtureAutoDetect: OpaqueToken;
2424

2525
/** @experimental */
26-
export declare var ComponentFixtureNoNgZone: OpaqueToken;
26+
export declare const ComponentFixtureNoNgZone: OpaqueToken;
2727

2828
/** @experimental */
2929
export declare function discardPeriodicTasks(): void;

0 commit comments

Comments
 (0)