) and grouping elements (
,
- * )).
- *
- * Grouping elements (, ) are treated as regular elements since we
- * can query for and , so they behave like regular elements from
- * this point of view.
- */
- it('should not descend into when descendants: false', () => {
- let elToQuery;
-
- /**
- *
- *
- *
- * class Cmpt {
- * @ViewChildren('foo') deep;
- * @ViewChildren('foo', {descendants: false}) shallow;
- * }
- */
- const Cmpt = createComponent(
- 'cmpt',
- function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵelementContainerStart(0);
- {
- ɵɵelement(1, 'div', null, 0);
- elToQuery = getNativeByIndex(3, getLView());
- }
- ɵɵelementContainerEnd();
- }
- },
- 3, 0, [], [],
- function(rf: RenderFlags, ctx: any) {
- if (rf & RenderFlags.Create) {
- ɵɵviewQuery(['foo'], true, ElementRef);
- ɵɵviewQuery(['foo'], false, ElementRef);
- }
- if (rf & RenderFlags.Update) {
- let tmp: any;
- ɵɵqueryRefresh(tmp = ɵɵloadQuery>()) &&
- (ctx.deep = tmp as QueryList);
- ɵɵqueryRefresh(tmp = ɵɵloadQuery>()) &&
- (ctx.shallow = tmp as QueryList);
- }
- },
- [], [], undefined, [['foo', '']]);
-
- const fixture = new ComponentFixture(Cmpt);
- const deepQList = fixture.component.deep;
- const shallowQList = fixture.component.shallow;
- expect(deepQList.length).toBe(1);
- expect(shallowQList.length).toBe(0);
- });
-
it('should read ViewContainerRef from element nodes when explicitly asked for', () => {
/**
*