@@ -147,12 +147,8 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver {
147
147
// Note: queries start with id 1 so we can use the number in a Bloom filter!
148
148
const queryId = queryIndex + 1 ;
149
149
const bindingType = query . first ? QueryBindingType . First : QueryBindingType . All ;
150
- let flags = NodeFlags . TypeViewQuery ;
151
- if ( queryIds . staticQueryIds . has ( queryId ) ) {
152
- flags |= NodeFlags . StaticQuery ;
153
- } else {
154
- flags |= NodeFlags . DynamicQuery ;
155
- }
150
+ const flags =
151
+ NodeFlags . TypeViewQuery | calcStaticDynamicQueryFlags ( queryIds , queryId , query . first ) ;
156
152
this . nodes . push ( ( ) => ( {
157
153
sourceSpan : null ,
158
154
nodeFlags : flags ,
@@ -491,15 +487,9 @@ class ViewBuilder implements TemplateAstVisitor, LocalResolver {
491
487
this . nodes . push ( null ) ;
492
488
493
489
dirAst . directive . queries . forEach ( ( query , queryIndex ) => {
494
- let flags = NodeFlags . TypeContentQuery ;
495
490
const queryId = dirAst . contentQueryStartId + queryIndex ;
496
- // Note: We only make queries static that query for a single item.
497
- // This is because of backwards compatibility with the old view compiler...
498
- if ( queryIds . staticQueryIds . has ( queryId ) && query . first ) {
499
- flags |= NodeFlags . StaticQuery ;
500
- } else {
501
- flags |= NodeFlags . DynamicQuery ;
502
- }
491
+ const flags =
492
+ NodeFlags . TypeContentQuery | calcStaticDynamicQueryFlags ( queryIds , queryId , query . first ) ;
503
493
const bindingType = query . first ? QueryBindingType . First : QueryBindingType . All ;
504
494
this . nodes . push ( ( ) => ( {
505
495
sourceSpan : dirAst . sourceSpan ,
@@ -1194,3 +1184,16 @@ function elementEventNameAndTarget(
1194
1184
return eventAst ;
1195
1185
}
1196
1186
}
1187
+
1188
+ function calcStaticDynamicQueryFlags (
1189
+ queryIds : StaticAndDynamicQueryIds , queryId : number , isFirst : boolean ) {
1190
+ let flags = NodeFlags . None ;
1191
+ // Note: We only make queries static that query for a single item.
1192
+ // This is because of backwards compatibility with the old view compiler...
1193
+ if ( isFirst && ( queryIds . staticQueryIds . has ( queryId ) || ! queryIds . dynamicQueryIds . has ( queryId ) ) ) {
1194
+ flags |= NodeFlags . StaticQuery ;
1195
+ } else {
1196
+ flags |= NodeFlags . DynamicQuery ;
1197
+ }
1198
+ return flags ;
1199
+ }
0 commit comments