@@ -418,14 +418,8 @@ export class ProtoElementInjector {
418
418
private static _createHostInjectorBindingData ( dirBindings : List < ResolvedBinding > ,
419
419
bd : List < BindingData > ,
420
420
firstBindingIsComponent : boolean ) {
421
- var visitedIds : Map < number , boolean > = new Map ( ) ;
422
421
ListWrapper . forEach ( dirBindings , dirBinding => {
423
422
ListWrapper . forEach ( dirBinding . resolvedHostInjectables , b => {
424
- if ( visitedIds . has ( b . key . id ) ) {
425
- throw new BaseException (
426
- `Multiple directives defined the same host injectable: "${ stringify ( b . key . token ) } "` ) ;
427
- }
428
- visitedIds . set ( b . key . id , true ) ;
429
423
bd . push ( ProtoElementInjector . _createBindingData ( firstBindingIsComponent , dirBinding ,
430
424
dirBindings ,
431
425
ProtoElementInjector . _createBinding ( b ) ) ) ;
@@ -948,6 +942,10 @@ export class ElementInjector extends TreeNode<ElementInjector> {
948
942
}
949
943
}
950
944
945
+ addDirectivesMatchingQuery ( query : Query , list : any [ ] ) : void {
946
+ this . _strategy . addDirectivesMatchingQuery ( query , list ) ;
947
+ }
948
+
951
949
private _buildQueries ( ) : void {
952
950
if ( isPresent ( this . _proto ) ) {
953
951
this . _strategy . buildQueries ( ) ;
@@ -1158,6 +1156,7 @@ interface _ElementInjectorStrategy {
1158
1156
getComponent ( ) : any ;
1159
1157
isComponentKey ( key : Key ) : boolean ;
1160
1158
buildQueries ( ) : void ;
1159
+ addDirectivesMatchingQuery ( q : Query , res : any [ ] ) : void ;
1161
1160
getObjByKeyId ( keyId : number , visibility : number ) : any ;
1162
1161
getDirectiveAtIndex ( index : number ) : any ;
1163
1162
getComponentBinding ( ) : DirectiveBinding ;
@@ -1234,17 +1233,18 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
1234
1233
1235
1234
hydrate ( ) : void {
1236
1235
var p = this . _protoStrategy ;
1236
+ var e = this . _ei ;
1237
1237
1238
- if ( isPresent ( p . _keyId0 ) ) this . getObjByKeyId ( p . _keyId0 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1239
- if ( isPresent ( p . _keyId1 ) ) this . getObjByKeyId ( p . _keyId1 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1240
- if ( isPresent ( p . _keyId2 ) ) this . getObjByKeyId ( p . _keyId2 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1241
- if ( isPresent ( p . _keyId3 ) ) this . getObjByKeyId ( p . _keyId3 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1242
- if ( isPresent ( p . _keyId4 ) ) this . getObjByKeyId ( p . _keyId4 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1243
- if ( isPresent ( p . _keyId5 ) ) this . getObjByKeyId ( p . _keyId5 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1244
- if ( isPresent ( p . _keyId6 ) ) this . getObjByKeyId ( p . _keyId6 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1245
- if ( isPresent ( p . _keyId7 ) ) this . getObjByKeyId ( p . _keyId7 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1246
- if ( isPresent ( p . _keyId8 ) ) this . getObjByKeyId ( p . _keyId8 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1247
- if ( isPresent ( p . _keyId9 ) ) this . getObjByKeyId ( p . _keyId9 , LIGHT_DOM_AND_SHADOW_DOM ) ;
1238
+ if ( isPresent ( p . _keyId0 ) && isBlank ( this . _obj0 ) ) this . _obj0 = e . _new ( p . _binding0 ) ;
1239
+ if ( isPresent ( p . _keyId1 ) && isBlank ( this . _obj1 ) ) this . _obj1 = e . _new ( p . _binding1 ) ;
1240
+ if ( isPresent ( p . _keyId2 ) && isBlank ( this . _obj2 ) ) this . _obj2 = e . _new ( p . _binding2 ) ;
1241
+ if ( isPresent ( p . _keyId3 ) && isBlank ( this . _obj3 ) ) this . _obj3 = e . _new ( p . _binding3 ) ;
1242
+ if ( isPresent ( p . _keyId4 ) && isBlank ( this . _obj4 ) ) this . _obj4 = e . _new ( p . _binding4 ) ;
1243
+ if ( isPresent ( p . _keyId5 ) && isBlank ( this . _obj5 ) ) this . _obj5 = e . _new ( p . _binding5 ) ;
1244
+ if ( isPresent ( p . _keyId6 ) && isBlank ( this . _obj6 ) ) this . _obj6 = e . _new ( p . _binding6 ) ;
1245
+ if ( isPresent ( p . _keyId7 ) && isBlank ( this . _obj7 ) ) this . _obj7 = e . _new ( p . _binding7 ) ;
1246
+ if ( isPresent ( p . _keyId8 ) && isBlank ( this . _obj8 ) ) this . _obj8 = e . _new ( p . _binding8 ) ;
1247
+ if ( isPresent ( p . _keyId9 ) && isBlank ( this . _obj9 ) ) this . _obj9 = e . _new ( p . _binding9 ) ;
1248
1248
}
1249
1249
1250
1250
getComponent ( ) : any { return this . _obj0 ; }
@@ -1288,6 +1288,20 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
1288
1288
}
1289
1289
}
1290
1290
1291
+ addDirectivesMatchingQuery ( query : Query , list : any [ ] ) : void {
1292
+ var p = this . _protoStrategy ;
1293
+ if ( isPresent ( p . _binding0 ) && p . _binding0 . key . token === query . selector ) list . push ( this . _obj0 ) ;
1294
+ if ( isPresent ( p . _binding1 ) && p . _binding1 . key . token === query . selector ) list . push ( this . _obj1 ) ;
1295
+ if ( isPresent ( p . _binding2 ) && p . _binding2 . key . token === query . selector ) list . push ( this . _obj2 ) ;
1296
+ if ( isPresent ( p . _binding3 ) && p . _binding3 . key . token === query . selector ) list . push ( this . _obj3 ) ;
1297
+ if ( isPresent ( p . _binding4 ) && p . _binding4 . key . token === query . selector ) list . push ( this . _obj4 ) ;
1298
+ if ( isPresent ( p . _binding5 ) && p . _binding5 . key . token === query . selector ) list . push ( this . _obj5 ) ;
1299
+ if ( isPresent ( p . _binding6 ) && p . _binding6 . key . token === query . selector ) list . push ( this . _obj6 ) ;
1300
+ if ( isPresent ( p . _binding7 ) && p . _binding7 . key . token === query . selector ) list . push ( this . _obj7 ) ;
1301
+ if ( isPresent ( p . _binding8 ) && p . _binding8 . key . token === query . selector ) list . push ( this . _obj8 ) ;
1302
+ if ( isPresent ( p . _binding9 ) && p . _binding9 . key . token === query . selector ) list . push ( this . _obj9 ) ;
1303
+ }
1304
+
1291
1305
getObjByKeyId ( keyId : number , visibility : number ) : any {
1292
1306
var p = this . _protoStrategy ;
1293
1307
@@ -1406,8 +1420,8 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
1406
1420
var p = this . _protoStrategy ;
1407
1421
1408
1422
for ( var i = 0 ; i < p . _keyIds . length ; i ++ ) {
1409
- if ( isPresent ( p . _keyIds [ i ] ) ) {
1410
- this . getObjByKeyId ( p . _keyIds [ i ] , LIGHT_DOM_AND_SHADOW_DOM ) ;
1423
+ if ( isPresent ( p . _keyIds [ i ] ) && isBlank ( this . _objs [ i ] ) ) {
1424
+ this . _objs [ i ] = this . _ei . _new ( p . _bindings [ i ] ) ;
1411
1425
}
1412
1426
}
1413
1427
}
@@ -1429,6 +1443,15 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {
1429
1443
}
1430
1444
}
1431
1445
1446
+ addDirectivesMatchingQuery ( query : Query , list : any [ ] ) : void {
1447
+ var p = this . _protoStrategy ;
1448
+
1449
+ for ( var i = 0 ; i < p . _bindings . length ; i ++ ) {
1450
+ if ( p . _bindings [ i ] . key . token === query . selector ) list . push ( this . _objs [ i ] ) ;
1451
+ }
1452
+ }
1453
+
1454
+
1432
1455
getObjByKeyId ( keyId : number , visibility : number ) : any {
1433
1456
var p = this . _protoStrategy ;
1434
1457
@@ -1518,8 +1541,6 @@ class QueryRef {
1518
1541
}
1519
1542
1520
1543
private _aggregateDirective ( inj : ElementInjector , aggregator : List < any > ) : void {
1521
- if ( inj . hasDirective ( this . query . selector ) ) {
1522
- aggregator . push ( inj . get ( this . query . selector ) ) ;
1523
- }
1544
+ inj . addDirectivesMatchingQuery ( this . query , aggregator ) ;
1524
1545
}
1525
1546
}
0 commit comments