@@ -3,6 +3,7 @@ import {ListWrapper} from 'facade/collection';
33import { ProtoWatchGroup , WatchGroup , WatchGroupDispatcher } from 'change_detection/watch_group' ;
44import { Record } from 'change_detection/record' ;
55import { ProtoElementInjector , ElementInjector } from './element_injector' ;
6+ import { ElementBinder } from './element_binder' ;
67import { SetterFn } from 'change_detection/facade' ;
78import { FIELD , IMPLEMENTS , int , isPresent , isBlank } from 'facade/lang' ;
89import { List } from 'facade/collection' ;
@@ -57,19 +58,16 @@ export class View {
5758
5859export class ProtoView {
5960 @FIELD ( 'final _template:TemplateElement' )
60- @FIELD ( 'final _bindings:List' )
61- @FIELD ( 'final _protoElementInjectors:List<ProtoElementInjector>' )
61+ @FIELD ( 'final _elementBinders:List<ElementBinder>' )
6262 @FIELD ( 'final _protoWatchGroup:ProtoWatchGroup' )
6363 @FIELD ( 'final _useRootElement:bool' )
6464 constructor (
6565 template :TemplateElement ,
66- bindings :List ,
67- protoElementInjectors :List ,
66+ elementBinders :List ,
6867 protoWatchGroup :ProtoWatchGroup ,
6968 useRootElement :boolean ) {
7069 this . _template = template ;
71- this . _bindings = bindings ;
72- this . _protoElementInjectors = protoElementInjectors ;
70+ this . _elementBinders = elementBinders ;
7371 this . _protoWatchGroup = protoWatchGroup ;
7472
7573 // not implemented
@@ -79,31 +77,32 @@ export class ProtoView {
7977 instantiate ( context , appInjector :Injector ) :View {
8078 var fragment = DOM . clone ( this . _template . content ) ;
8179 var elements = DOM . querySelectorAll ( fragment , ".ng-binding" ) ;
82- var protos = this . _protoElementInjectors ;
80+ var binders = this . _elementBinders ;
8381
8482 /**
8583 * TODO: vsavkin: benchmark
8684 * If this performs poorly, the five loops can be collapsed into one.
8785 */
88- var elementInjectors = ProtoView . _createElementInjectors ( elements , protos ) ;
86+ var elementInjectors = ProtoView . _createElementInjectors ( elements , binders ) ;
8987 var rootElementInjectors = ProtoView . _rootElementInjectors ( elementInjectors ) ;
90- var textNodes = ProtoView . _textNodes ( elements , protos ) ;
91- var bindElements = ProtoView . _bindElements ( elements , protos ) ;
88+ var textNodes = ProtoView . _textNodes ( elements , binders ) ;
89+ var bindElements = ProtoView . _bindElements ( elements , binders ) ;
9290 ProtoView . _instantiateDirectives ( elementInjectors , appInjector ) ;
9391
9492 return new View ( fragment , elementInjectors , rootElementInjectors , textNodes ,
9593 bindElements , this . _protoWatchGroup , context ) ;
9694 }
9795
98- static _createElementInjectors ( elements , protos ) {
99- var injectors = ListWrapper . createFixedSize ( protos . length ) ;
100- for ( var i = 0 ; i < protos . length ; ++ i ) {
101- injectors [ i ] = ProtoView . _createElementInjector ( elements [ i ] , protos [ i ] ) ;
96+ static _createElementInjectors ( elements , binders ) {
97+ var injectors = ListWrapper . createFixedSize ( binders . length ) ;
98+ for ( var i = 0 ; i < binders . length ; ++ i ) {
99+ injectors [ i ] = ProtoView . _createElementInjector (
100+ elements [ i ] , binders [ i ] . protoElementInjector ) ;
102101 }
103102 // Cannot be rolled into loop above, because parentInjector pointers need
104103 // to be set on the children.
105- for ( var i = 0 ; i < protos . length ; ++ i ) {
106- protos [ i ] . clearElementInjector ( ) ;
104+ for ( var i = 0 ; i < binders . length ; ++ i ) {
105+ binders [ i ] . protoElementInjector . clearElementInjector ( ) ;
107106 }
108107 return injectors ;
109108 }
@@ -124,19 +123,19 @@ export class ProtoView {
124123 return ListWrapper . filter ( injectors , inj => isPresent ( inj ) && isBlank ( inj . parent ) ) ;
125124 }
126125
127- static _textNodes ( elements , protos ) {
126+ static _textNodes ( elements , binders ) {
128127 var textNodes = [ ] ;
129- for ( var i = 0 ; i < protos . length ; ++ i ) {
128+ for ( var i = 0 ; i < binders . length ; ++ i ) {
130129 ProtoView . _collectTextNodes ( textNodes , elements [ i ] ,
131- protos [ i ] . textNodeIndices ) ;
130+ binders [ i ] . textNodeIndices ) ;
132131 }
133132 return textNodes ;
134133 }
135134
136- static _bindElements ( elements , protos ) :List < Element > {
135+ static _bindElements ( elements , binders ) :List < Element > {
137136 var bindElements = [ ] ;
138- for ( var i = 0 ; i < protos . length ; ++ i ) {
139- if ( protos [ i ] . hasElementPropertyBindings ) ListWrapper . push (
137+ for ( var i = 0 ; i < binders . length ; ++ i ) {
138+ if ( binders [ i ] . hasElementPropertyBindings ) ListWrapper . push (
140139 bindElements , elements [ i ] ) ;
141140 }
142141 return bindElements ;
0 commit comments