@@ -24,7 +24,7 @@ import {unusedValueExportToPlacateAjd as unused1} from './interfaces/definition'
24
24
import { unusedValueExportToPlacateAjd as unused2 } from './interfaces/injector' ;
25
25
import { TContainerNode , TElementContainerNode , TElementNode , TNode , TNodeType , unusedValueExportToPlacateAjd as unused3 } from './interfaces/node' ;
26
26
import { LQueries , unusedValueExportToPlacateAjd as unused4 } from './interfaces/query' ;
27
- import { CONTENT_QUERIES , HEADER_OFFSET , LView , QUERIES , TVIEW } from './interfaces/view' ;
27
+ import { CONTENT_QUERIES , HEADER_OFFSET , LView , QUERIES , TVIEW , TView } from './interfaces/view' ;
28
28
import { getCurrentQueryIndex , getIsParent , getLView , isCreationMode , setCurrentQueryIndex } from './state' ;
29
29
import { loadInternal } from './util/view_utils' ;
30
30
import { createElementRef , createTemplateRef } from './view_engine_compatibility' ;
@@ -370,12 +370,13 @@ type QueryList_<T> = QueryList<T>& {_valuesTree: any[], _static: boolean};
370
370
*/
371
371
function query < T > (
372
372
// TODO: "read" should be an AbstractType (FW-486)
373
- lView : LView , predicate : Type < any > | string [ ] , descend : boolean , read : any ) : QueryList < T > {
373
+ lView : LView , predicate : Type < any > | string [ ] , descend : boolean , read : any ,
374
+ isStatic : boolean ) : QueryList < T > {
374
375
ngDevMode && assertPreviousIsParent ( getIsParent ( ) ) ;
375
376
const queryList = new QueryList < T > ( ) as QueryList_ < T > ;
376
377
const queries = lView [ QUERIES ] || ( lView [ QUERIES ] = new LQueries_ ( null , null , null ) ) ;
377
378
queryList . _valuesTree = [ ] ;
378
- queryList . _static = false ;
379
+ queryList . _static = isStatic ;
379
380
queries . track ( queryList , predicate , descend , read ) ;
380
381
storeCleanupWithContext ( lView , queryList , queryList . destroy ) ;
381
382
return queryList ;
@@ -415,12 +416,10 @@ export function ɵɵqueryRefresh(queryList: QueryList<any>): boolean {
415
416
export function ɵɵstaticViewQuery < T > (
416
417
// TODO(FW-486): "read" should be an AbstractType
417
418
predicate : Type < any > | string [ ] , descend : boolean , read : any ) : void {
418
- const queryList = ɵɵviewQuery ( predicate , descend , read ) as QueryList_ < T > ;
419
- const tView = getLView ( ) [ TVIEW ] ;
420
- queryList . _static = true ;
421
- if ( ! tView . staticViewQueries ) {
422
- tView . staticViewQueries = true ;
423
- }
419
+ const lView = getLView ( ) ;
420
+ const tView = lView [ TVIEW ] ;
421
+ viewQueryInternal ( lView , tView , predicate , descend , read , true ) ;
422
+ tView . staticViewQueries = true ;
424
423
}
425
424
426
425
/**
@@ -438,14 +437,20 @@ export function ɵɵviewQuery<T>(
438
437
predicate : Type < any > | string [ ] , descend : boolean , read : any ) : QueryList < T > {
439
438
const lView = getLView ( ) ;
440
439
const tView = lView [ TVIEW ] ;
440
+ return viewQueryInternal ( lView , tView , predicate , descend , read , false ) ;
441
+ }
442
+
443
+ function viewQueryInternal < T > (
444
+ lView : LView , tView : TView , predicate : Type < any > | string [ ] , descend : boolean , read : any ,
445
+ isStatic : boolean ) : QueryList < T > {
441
446
if ( tView . firstTemplatePass ) {
442
447
tView . expandoStartIndex ++ ;
443
448
}
444
449
const index = getCurrentQueryIndex ( ) ;
445
- const viewQuery : QueryList < T > = query < T > ( lView , predicate , descend , read ) ;
446
- store ( index - HEADER_OFFSET , viewQuery ) ;
450
+ const queryList : QueryList < T > = query < T > ( lView , predicate , descend , read , isStatic ) ;
451
+ store ( index - HEADER_OFFSET , queryList ) ;
447
452
setCurrentQueryIndex ( index + 1 ) ;
448
- return viewQuery ;
453
+ return queryList ;
449
454
}
450
455
451
456
/**
@@ -477,7 +482,15 @@ export function ɵɵcontentQuery<T>(
477
482
read : any ) : QueryList < T > {
478
483
const lView = getLView ( ) ;
479
484
const tView = lView [ TVIEW ] ;
480
- const contentQuery : QueryList < T > = query < T > ( lView , predicate , descend , read ) ;
485
+ return contentQueryInternal ( lView , tView , directiveIndex , predicate , descend , read , false ) ;
486
+ }
487
+
488
+ function contentQueryInternal < T > (
489
+ lView : LView , tView : TView , directiveIndex : number , predicate : Type < any > | string [ ] ,
490
+ descend : boolean ,
491
+ // TODO(FW-486): "read" should be an AbstractType
492
+ read : any , isStatic : boolean ) : QueryList < T > {
493
+ const contentQuery : QueryList < T > = query < T > ( lView , predicate , descend , read , isStatic ) ;
481
494
( lView [ CONTENT_QUERIES ] || ( lView [ CONTENT_QUERIES ] = [ ] ) ) . push ( contentQuery ) ;
482
495
if ( tView . firstTemplatePass ) {
483
496
const tViewContentQueries = tView . contentQueries || ( tView . contentQueries = [ ] ) ;
@@ -506,12 +519,10 @@ export function ɵɵstaticContentQuery<T>(
506
519
directiveIndex : number , predicate : Type < any > | string [ ] , descend : boolean ,
507
520
// TODO(FW-486): "read" should be an AbstractType
508
521
read : any ) : void {
509
- const queryList = ɵɵcontentQuery ( directiveIndex , predicate , descend , read ) as QueryList_ < T > ;
510
- const tView = getLView ( ) [ TVIEW ] ;
511
- queryList . _static = true ;
512
- if ( ! tView . staticContentQueries ) {
513
- tView . staticContentQueries = true ;
514
- }
522
+ const lView = getLView ( ) ;
523
+ const tView = lView [ TVIEW ] ;
524
+ contentQueryInternal ( lView , tView , directiveIndex , predicate , descend , read , true ) ;
525
+ tView . staticContentQueries = true ;
515
526
}
516
527
517
528
/**
0 commit comments