Skip to content

Commit

Permalink
fix(ContentChild): query descendants by default
Browse files Browse the repository at this point in the history
fixes #1645
  • Loading branch information
vicb authored and alexeagle committed Sep 19, 2016
1 parent cba885a commit 0dc15eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/@angular/core/src/metadata/di.ts
Expand Up @@ -275,7 +275,7 @@ export const ContentChild: ContentChildDecorator = makePropDecorator(
['selector', undefined], { ['selector', undefined], {
first: true, first: true,
isViewQuery: false, isViewQuery: false,
descendants: false, descendants: true,
read: undefined, read: undefined,
} }
], ],
Expand Down
11 changes: 11 additions & 0 deletions modules/@angular/core/test/linker/query_integration_spec.ts
Expand Up @@ -250,6 +250,17 @@ export function main() {
expect(comp.textDirChild.text).toEqual('ca'); expect(comp.textDirChild.text).toEqual('ca');
}); });


it('should contain the first descendant content child', () => {
const template = '<needs-content-child-read>' +
'<div dir><div #q text="ca"></div></div>' +
'</needs-content-child-read>';
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', () => { it('should contain the first view child', () => {
const template = '<needs-view-child-read></needs-view-child-read>'; const template = '<needs-view-child-read></needs-view-child-read>';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/core/testing/index.d.ts
Expand Up @@ -20,10 +20,10 @@ export declare class ComponentFixture<T> {
} }


/** @experimental */ /** @experimental */
export declare var ComponentFixtureAutoDetect: OpaqueToken; export declare const ComponentFixtureAutoDetect: OpaqueToken;


/** @experimental */ /** @experimental */
export declare var ComponentFixtureNoNgZone: OpaqueToken; export declare const ComponentFixtureNoNgZone: OpaqueToken;


/** @experimental */ /** @experimental */
export declare function discardPeriodicTasks(): void; export declare function discardPeriodicTasks(): void;
Expand Down

3 comments on commit 0dc15eb

@lacolaco
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicb This commit should be related to #11645

Opened. #11871

@vicb
Copy link
Contributor Author

@vicb vicb commented on 0dc15eb Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@cagataycivici
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this inconsistent to @ContentChildren, which does not query descendants.

Please sign in to comment.