@@ -189,10 +189,28 @@ export class TreeNode<T extends TreeNode<any>> {
189189 }
190190}
191191
192- export class DirectiveDependency extends Dependency {
192+ export class DependencyWithVisibility extends Dependency {
193193 constructor ( key : Key , asPromise : boolean , lazy : boolean , optional : boolean , properties : List < any > ,
194- public visibility : Visibility , public attributeName : string , public queryDirective ) {
194+ public visibility : Visibility ) {
195195 super ( key , asPromise , lazy , optional , properties ) ;
196+ }
197+
198+ static createFrom ( d : Dependency ) : Dependency {
199+ return new DependencyWithVisibility ( d . key , d . asPromise , d . lazy , d . optional , d . properties ,
200+ DependencyWithVisibility . _visibility ( d . properties ) ) ;
201+ }
202+
203+ static _visibility ( properties ) : Visibility {
204+ if ( properties . length == 0 ) return self ;
205+ var p = ListWrapper . find ( properties , p => p instanceof Visibility ) ;
206+ return isPresent ( p ) ? p : self ;
207+ }
208+ }
209+
210+ export class DirectiveDependency extends DependencyWithVisibility {
211+ constructor ( key : Key , asPromise : boolean , lazy : boolean , optional : boolean , properties : List < any > ,
212+ visibility : Visibility , public attributeName : string , public queryDirective ) {
213+ super ( key , asPromise , lazy , optional , properties , visibility ) ;
196214 this . _verify ( ) ;
197215 }
198216
@@ -207,17 +225,11 @@ export class DirectiveDependency extends Dependency {
207225
208226 static createFrom ( d : Dependency ) : Dependency {
209227 return new DirectiveDependency ( d . key , d . asPromise , d . lazy , d . optional , d . properties ,
210- DirectiveDependency . _visibility ( d . properties ) ,
228+ DependencyWithVisibility . _visibility ( d . properties ) ,
211229 DirectiveDependency . _attributeName ( d . properties ) ,
212230 DirectiveDependency . _query ( d . properties ) ) ;
213231 }
214232
215- static _visibility ( properties ) : Visibility {
216- if ( properties . length == 0 ) return self ;
217- var p = ListWrapper . find ( properties , p => p instanceof Visibility ) ;
218- return isPresent ( p ) ? p : self ;
219- }
220-
221233 static _attributeName ( properties ) : string {
222234 var p = ListWrapper . find ( properties , ( p ) => p instanceof Attribute ) ;
223235 return isPresent ( p ) ? p . attributeName : null ;
@@ -476,16 +488,24 @@ export class ProtoElementInjector {
476488 private static _createHostInjectorBindingData ( bindings : List < ResolvedBinding > ,
477489 bd : List < BindingData > ) {
478490 ListWrapper . forEach ( bindings , b => {
479- ListWrapper . forEach ( b . resolvedHostInjectables ,
480- b => { ListWrapper . push ( bd , new BindingData ( b , LIGHT_DOM ) ) ; } ) ;
491+ ListWrapper . forEach ( b . resolvedHostInjectables , b => {
492+ ListWrapper . push ( bd , new BindingData ( ProtoElementInjector . _createBinding ( b ) , LIGHT_DOM ) ) ;
493+ } ) ;
481494 } ) ;
482495 }
483496
484497 private static _createViewInjectorBindingData ( bindings : List < ResolvedBinding > ,
485498 bd : List < BindingData > ) {
486499 var db = < DirectiveBinding > bindings [ 0 ] ;
487- ListWrapper . forEach ( db . resolvedViewInjectables ,
488- b => ListWrapper . push ( bd , new BindingData ( b , SHADOW_DOM ) ) ) ;
500+ ListWrapper . forEach (
501+ db . resolvedViewInjectables ,
502+ b => ListWrapper . push ( bd ,
503+ new BindingData ( ProtoElementInjector . _createBinding ( b ) , SHADOW_DOM ) ) ) ;
504+ }
505+
506+ private static _createBinding ( b : ResolvedBinding ) {
507+ var deps = ListWrapper . map ( b . dependencies , d => DependencyWithVisibility . createFrom ( d ) ) ;
508+ return new ResolvedBinding ( b . key , b . factory , deps , b . providedAsPromise ) ;
489509 }
490510
491511 constructor ( parent : ProtoElementInjector , index : int , bd : List < BindingData > ,
@@ -909,9 +929,9 @@ export class ElementInjector extends TreeNode<ElementInjector> {
909929 return obj ;
910930 }
911931
912- private _getByDependency ( dep : Dependency , requestor : Key ) {
932+ private _getByDependency ( dep : DependencyWithVisibility , requestor : Key ) {
913933 if ( ! ( dep instanceof DirectiveDependency ) ) {
914- return this . _getByKey ( dep . key , self , dep . optional , requestor ) ;
934+ return this . _getByKey ( dep . key , dep . visibility , dep . optional , requestor ) ;
915935 }
916936
917937 var dirDep = < DirectiveDependency > dep ;
0 commit comments