@@ -383,7 +383,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
383383 this . _preBuiltObjects = null ;
384384 this . _strategy . callOnDestroy ( ) ;
385385 this . _strategy . dehydrate ( ) ;
386- this . _queryStrategy . clearQueryLists ( ) ;
386+ this . _queryStrategy . dehydrate ( ) ;
387387 }
388388
389389 hydrate ( imperativelyCreatedInjector : Injector , host : ElementInjector ,
@@ -392,6 +392,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
392392 this . _preBuiltObjects = preBuiltObjects ;
393393
394394 this . _reattachInjectors ( imperativelyCreatedInjector ) ;
395+ this . _queryStrategy . hydrate ( ) ;
395396 this . _strategy . hydrate ( ) ;
396397
397398 this . hydrated = true ;
@@ -604,7 +605,8 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
604605interface _QueryStrategy {
605606 setContentQueriesAsDirty ( ) : void ;
606607 setViewQueriesAsDirty ( ) : void ;
607- clearQueryLists ( ) : void ;
608+ hydrate ( ) : void ;
609+ dehydrate ( ) : void ;
608610 updateContentQueries ( ) : void ;
609611 updateViewQueries ( ) : void ;
610612 findQuery ( query : QueryMetadata ) : QueryRef ;
@@ -613,7 +615,8 @@ interface _QueryStrategy {
613615class _EmptyQueryStrategy implements _QueryStrategy {
614616 setContentQueriesAsDirty ( ) : void { }
615617 setViewQueriesAsDirty ( ) : void { }
616- clearQueryLists ( ) : void { }
618+ hydrate ( ) : void { }
619+ dehydrate ( ) : void { }
617620 updateContentQueries ( ) : void { }
618621 updateViewQueries ( ) : void { }
619622 findQuery ( query : QueryMetadata ) : QueryRef {
@@ -632,9 +635,9 @@ class InlineQueryStrategy implements _QueryStrategy {
632635
633636 constructor ( ei : ElementInjector ) {
634637 var protoRefs = ei . _proto . protoQueryRefs ;
635- if ( protoRefs . length > 0 ) this . query0 = new QueryRef ( protoRefs [ 0 ] , new QueryList < any > ( ) , ei ) ;
636- if ( protoRefs . length > 1 ) this . query1 = new QueryRef ( protoRefs [ 1 ] , new QueryList < any > ( ) , ei ) ;
637- if ( protoRefs . length > 2 ) this . query2 = new QueryRef ( protoRefs [ 2 ] , new QueryList < any > ( ) , ei ) ;
638+ if ( protoRefs . length > 0 ) this . query0 = new QueryRef ( protoRefs [ 0 ] , ei ) ;
639+ if ( protoRefs . length > 1 ) this . query1 = new QueryRef ( protoRefs [ 1 ] , ei ) ;
640+ if ( protoRefs . length > 2 ) this . query2 = new QueryRef ( protoRefs [ 2 ] , ei ) ;
638641 }
639642
640643 setContentQueriesAsDirty ( ) : void {
@@ -649,39 +652,39 @@ class InlineQueryStrategy implements _QueryStrategy {
649652 if ( isPresent ( this . query2 ) && this . query2 . isViewQuery ) this . query2 . dirty = true ;
650653 }
651654
652- clearQueryLists ( ) : void {
653- if ( isPresent ( this . query0 ) ) this . query0 . reset ( ) ;
654- if ( isPresent ( this . query1 ) ) this . query1 . reset ( ) ;
655- if ( isPresent ( this . query2 ) ) this . query2 . reset ( ) ;
655+ hydrate ( ) : void {
656+ if ( isPresent ( this . query0 ) ) this . query0 . hydrate ( ) ;
657+ if ( isPresent ( this . query1 ) ) this . query1 . hydrate ( ) ;
658+ if ( isPresent ( this . query2 ) ) this . query2 . hydrate ( ) ;
659+ }
660+
661+ dehydrate ( ) : void {
662+ if ( isPresent ( this . query0 ) ) this . query0 . dehydrate ( ) ;
663+ if ( isPresent ( this . query1 ) ) this . query1 . dehydrate ( ) ;
664+ if ( isPresent ( this . query2 ) ) this . query2 . dehydrate ( ) ;
656665 }
657666
658667 updateContentQueries ( ) {
659668 if ( isPresent ( this . query0 ) && ! this . query0 . isViewQuery ) {
660669 this . query0 . update ( ) ;
661- this . query0 . list . fireCallbacks ( ) ;
662670 }
663671 if ( isPresent ( this . query1 ) && ! this . query1 . isViewQuery ) {
664672 this . query1 . update ( ) ;
665- this . query1 . list . fireCallbacks ( ) ;
666673 }
667674 if ( isPresent ( this . query2 ) && ! this . query2 . isViewQuery ) {
668675 this . query2 . update ( ) ;
669- this . query2 . list . fireCallbacks ( ) ;
670676 }
671677 }
672678
673679 updateViewQueries ( ) {
674680 if ( isPresent ( this . query0 ) && this . query0 . isViewQuery ) {
675681 this . query0 . update ( ) ;
676- this . query0 . list . fireCallbacks ( ) ;
677682 }
678683 if ( isPresent ( this . query1 ) && this . query1 . isViewQuery ) {
679684 this . query1 . update ( ) ;
680- this . query1 . list . fireCallbacks ( ) ;
681685 }
682686 if ( isPresent ( this . query2 ) && this . query2 . isViewQuery ) {
683687 this . query2 . update ( ) ;
684- this . query2 . list . fireCallbacks ( ) ;
685688 }
686689 }
687690
@@ -703,7 +706,7 @@ class DynamicQueryStrategy implements _QueryStrategy {
703706 queries : QueryRef [ ] ;
704707
705708 constructor ( ei : ElementInjector ) {
706- this . queries = ei . _proto . protoQueryRefs . map ( p => new QueryRef ( p , new QueryList < any > ( ) , ei ) ) ;
709+ this . queries = ei . _proto . protoQueryRefs . map ( p => new QueryRef ( p , ei ) ) ;
707710 }
708711
709712 setContentQueriesAsDirty ( ) : void {
@@ -720,10 +723,17 @@ class DynamicQueryStrategy implements _QueryStrategy {
720723 }
721724 }
722725
723- clearQueryLists ( ) : void {
726+ hydrate ( ) : void {
724727 for ( var i = 0 ; i < this . queries . length ; ++ i ) {
725728 var q = this . queries [ i ] ;
726- q . reset ( ) ;
729+ q . hydrate ( ) ;
730+ }
731+ }
732+
733+ dehydrate ( ) : void {
734+ for ( var i = 0 ; i < this . queries . length ; ++ i ) {
735+ var q = this . queries [ i ] ;
736+ q . dehydrate ( ) ;
727737 }
728738 }
729739
@@ -732,7 +742,6 @@ class DynamicQueryStrategy implements _QueryStrategy {
732742 var q = this . queries [ i ] ;
733743 if ( ! q . isViewQuery ) {
734744 q . update ( ) ;
735- q . list . fireCallbacks ( ) ;
736745 }
737746 }
738747 }
@@ -742,7 +751,6 @@ class DynamicQueryStrategy implements _QueryStrategy {
742751 var q = this . queries [ i ] ;
743752 if ( q . isViewQuery ) {
744753 q . update ( ) ;
745- q . list . fireCallbacks ( ) ;
746754 }
747755 }
748756 }
@@ -972,8 +980,10 @@ export class ProtoQueryRef {
972980}
973981
974982export class QueryRef {
975- constructor ( public protoQueryRef : ProtoQueryRef , public list : QueryList < any > ,
976- private originator : ElementInjector , public dirty : boolean = true ) { }
983+ public list : QueryList < any > ;
984+ public dirty : boolean ;
985+
986+ constructor ( public protoQueryRef : ProtoQueryRef , private originator : ElementInjector ) { }
977987
978988 get isViewQuery ( ) : boolean { return this . protoQueryRef . query . isViewQuery ; }
979989
@@ -991,6 +1001,8 @@ export class QueryRef {
9911001 this . protoQueryRef . setter ( dir , this . list ) ;
9921002 }
9931003 }
1004+
1005+ this . list . notifyOnChanges ( ) ;
9941006 }
9951007
9961008 private _update ( ) : void {
@@ -1073,9 +1085,10 @@ export class QueryRef {
10731085 inj . addDirectivesMatchingQuery ( this . protoQueryRef . query , aggregator ) ;
10741086 }
10751087
1076- reset ( ) : void {
1077- this . list . reset ( [ ] ) ;
1078- this . list . removeAllCallbacks ( ) ;
1088+ dehydrate ( ) : void { this . list = null ; }
1089+
1090+ hydrate ( ) : void {
1091+ this . list = new QueryList < any > ( ) ;
10791092 this . dirty = true ;
10801093 }
10811094}
0 commit comments