@@ -365,6 +365,30 @@ export function main() {
365365 } ) ;
366366 } ) ) ;
367367
368+ it ( 'should not be affected by other changes in the component' ,
369+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
370+ var template = '<needs-view-query-nested-if #q></needs-view-query-nested-if>' ;
371+
372+ tcb . overrideTemplate ( MyComp , template )
373+ . createAsync ( MyComp )
374+ . then ( ( view ) => {
375+ var q : NeedsViewQueryNestedIf = view . componentViewChildren [ 0 ] . getLocal ( "q" ) ;
376+
377+ view . detectChanges ( ) ;
378+
379+ expect ( q . query . length ) . toEqual ( 1 ) ;
380+ expect ( q . query . first . text ) . toEqual ( "1" ) ;
381+
382+ q . show = false ;
383+ view . detectChanges ( ) ;
384+
385+ expect ( q . query . length ) . toEqual ( 1 ) ;
386+ expect ( q . query . first . text ) . toEqual ( "1" ) ;
387+
388+ async . done ( ) ;
389+ } ) ;
390+ } ) ) ;
391+
368392 /* TODO(rado): fix and reenable.
369393
370394 it('should maintain directives in pre-order depth-first DOM order after dynamic insertion',
@@ -396,6 +420,12 @@ class TextDirective {
396420 constructor ( ) { }
397421}
398422
423+ @Directive ( { selector : '[dir]' } )
424+ @Injectable ( )
425+ class InertDirective {
426+ constructor ( ) { }
427+ }
428+
399429@Component ( { selector : 'needs-query' } )
400430@View ( {
401431 directives : [ NgFor , TextDirective ] ,
@@ -487,6 +517,22 @@ class NeedsViewQueryIf {
487517}
488518
489519
520+ @Component ( { selector : 'needs-view-query-nested-if' } )
521+ @View ( {
522+ directives : [ NgIf , InertDirective , TextDirective ] ,
523+ template : '<div text="1"><div *ng-if="show"><div dir></div></div></div>'
524+ } )
525+ @Injectable ( )
526+ class NeedsViewQueryNestedIf {
527+ show : boolean ;
528+ query : QueryList < TextDirective > ;
529+ constructor ( @ViewQuery ( TextDirective ) query : QueryList < TextDirective > ) {
530+ this . query = query ;
531+ this . show = true ;
532+ }
533+ }
534+
535+
490536@Component ( { selector : 'needs-view-query-order' } )
491537@View ( {
492538 directives : [ NgFor , TextDirective ] ,
@@ -511,8 +557,10 @@ class NeedsViewQueryOrder {
511557 NeedsViewQuery ,
512558 NeedsViewQueryDesc ,
513559 NeedsViewQueryIf ,
560+ NeedsViewQueryNestedIf ,
514561 NeedsViewQueryOrder ,
515562 TextDirective ,
563+ InertDirective ,
516564 NgIf ,
517565 NgFor
518566 ]
0 commit comments