fix(ContentChild): query descendants by default

fixes #1645
This commit is contained in:
Victor Berchet 2016-09-16 11:14:49 -07:00 committed by Alex Eagle
parent cba885a1fb
commit 0dc15eb64a
3 changed files with 14 additions and 3 deletions

View File

@ -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,
} }
], ],

View File

@ -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);

View File

@ -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;