@@ -70,50 +70,36 @@ export function main() {
7070 if ( isBlank ( appInjector ) ) appInjector = new Injector ( [ ] ) ;
7171 if ( isBlank ( props ) ) props = { } ;
7272
73- var proto = new ProtoElementInjector ( null , bindings ) ;
74- var inj = proto . instantiate ( { view : props [ "view" ] } ) ;
73+ var proto = new ProtoElementInjector ( null , 0 , bindings ) ;
74+ var inj = proto . instantiate ( { view : props [ "view" ] , parentElementInjector : null } ) ;
7575 inj . instantiateDirectives ( appInjector ) ;
7676 return inj ;
7777 }
7878
7979 function parentChildInjectors ( parentBindings , childBindings ) {
8080 var inj = new Injector ( [ ] ) ;
8181
82- var protoParent = new ProtoElementInjector ( null , parentBindings ) ;
83- var parent = protoParent . instantiate ( { view : null } ) ;
82+ var protoParent = new ProtoElementInjector ( null , 0 , parentBindings ) ;
83+ var parent = protoParent . instantiate ( { view : null , parentElementInjector : null } ) ;
8484 parent . instantiateDirectives ( inj ) ;
8585
86- var protoChild = new ProtoElementInjector ( protoParent , childBindings ) ;
87- var child = protoChild . instantiate ( { view : null } ) ;
86+ var protoChild = new ProtoElementInjector ( protoParent , 1 , childBindings ) ;
87+ var child = protoChild . instantiate ( { view : null , parentElementInjector : parent } ) ;
8888 child . instantiateDirectives ( inj ) ;
8989
9090 return child ;
9191 }
9292
9393 describe ( "ElementInjector" , function ( ) {
94- describe ( "proto injectors" , function ( ) {
95- it ( "should construct a proto tree" , function ( ) {
96- var p = new ProtoElementInjector ( null , [ ] ) ;
97- var c1 = new ProtoElementInjector ( p , [ ] ) ;
98- var c2 = new ProtoElementInjector ( p , [ ] ) ;
99-
100- expect ( humanize ( p , [
101- [ p , 'parent' ] ,
102- [ c1 , 'child1' ] ,
103- [ c2 , 'child2' ]
104- ] ) ) . toEqual ( [ "parent" , [ "child1" , "child2" ] ] ) ;
105- } ) ;
106- } ) ;
107-
10894 describe ( "instantiate" , function ( ) {
10995 it ( "should create an element injector" , function ( ) {
110- var protoParent = new ProtoElementInjector ( null , [ ] ) ;
111- var protoChild1 = new ProtoElementInjector ( protoParent , [ ] ) ;
112- var protoChild2 = new ProtoElementInjector ( protoParent , [ ] ) ;
96+ var protoParent = new ProtoElementInjector ( null , 0 , [ ] ) ;
97+ var protoChild1 = new ProtoElementInjector ( protoParent , 1 , [ ] ) ;
98+ var protoChild2 = new ProtoElementInjector ( protoParent , 2 , [ ] ) ;
11399
114- var p = protoParent . instantiate ( { view : null } ) ;
115- var c1 = protoChild1 . instantiate ( { view : null } ) ;
116- var c2 = protoChild2 . instantiate ( { view : null } ) ;
100+ var p = protoParent . instantiate ( { view : null , parentElementInjector : null } ) ;
101+ var c1 = protoChild1 . instantiate ( { view : null , parentElementInjector : p } ) ;
102+ var c2 = protoChild2 . instantiate ( { view : null , parentElementInjector : p } ) ;
117103
118104 expect ( humanize ( p , [
119105 [ p , 'parent' ] ,
@@ -125,12 +111,12 @@ export function main() {
125111
126112 describe ( "hasBindings" , function ( ) {
127113 it ( "should be true when there are bindings" , function ( ) {
128- var p = new ProtoElementInjector ( null , [ Directive ] ) ;
114+ var p = new ProtoElementInjector ( null , 0 , [ Directive ] ) ;
129115 expect ( p . hasBindings ) . toBeTruthy ( ) ;
130116 } ) ;
131117
132118 it ( "should be false otherwise" , function ( ) {
133- var p = new ProtoElementInjector ( null , [ ] ) ;
119+ var p = new ProtoElementInjector ( null , 0 , [ ] ) ;
134120 expect ( p . hasBindings ) . toBeFalsy ( ) ;
135121 } ) ;
136122 } ) ;
0 commit comments