@@ -65,6 +65,7 @@ EventHandler eventHandler(DirectiveInjector di) => di._eventHandler;
65
65
66
66
class DirectiveInjector implements DirectiveBinder {
67
67
static bool _isInit = false ;
68
+
68
69
static initUID () {
69
70
if (_isInit) return ;
70
71
_isInit = true ;
@@ -91,6 +92,7 @@ class DirectiveInjector implements DirectiveBinder {
91
92
if (_KEYS [i].uid != i) throw 'MISSORDERED KEYS ARRAY: ${_KEYS } at $i ' ;
92
93
}
93
94
}
95
+
94
96
static List <Key > _KEYS =
95
97
[ UNDEFINED_ID
96
98
, INJECTOR_KEY
@@ -128,6 +130,7 @@ class DirectiveInjector implements DirectiveBinder {
128
130
NgElement _ngElement;
129
131
ElementProbe _elementProbe;
130
132
133
+ // Keys, instances, parameter keys and factory functions
131
134
Key _key0 = null ; dynamic _obj0; List <Key > _pKeys0; Function _factory0;
132
135
Key _key1 = null ; dynamic _obj1; List <Key > _pKeys1; Function _factory1;
133
136
Key _key2 = null ; dynamic _obj2; List <Key > _pKeys2; Function _factory2;
@@ -148,11 +151,11 @@ class DirectiveInjector implements DirectiveBinder {
148
151
@Deprecated ("Deprecated. Use getFromParent instead." )
149
152
Object get parent => this ._parent;
150
153
151
- static _toVisId (Visibility v) => identical (v, Visibility .LOCAL )
154
+ static _toVisibilityId (Visibility v) => identical (v, Visibility .LOCAL )
152
155
? VISIBILITY_LOCAL
153
156
: (identical (v, Visibility .CHILDREN ) ? VISIBILITY_CHILDREN : VISIBILITY_DIRECT_CHILD );
154
157
155
- static _toVis (int id) {
158
+ static Visibility _toVisibility (int id) {
156
159
switch (id) {
157
160
case VISIBILITY_LOCAL : return Visibility .LOCAL ;
158
161
case VISIBILITY_DIRECT_CHILD : return Visibility .DIRECT_CHILD ;
@@ -185,7 +188,7 @@ class DirectiveInjector implements DirectiveBinder {
185
188
toInstanceOf,
186
189
inject: const [],
187
190
Visibility visibility: Visibility .LOCAL }) {
188
- if (key == null ) throw 'Key is required' ;
191
+ assert (key != null );
189
192
if (key is ! Key ) key = new Key (key);
190
193
if (inject is ! List ) inject = [inject];
191
194
@@ -197,13 +200,13 @@ class DirectiveInjector implements DirectiveBinder {
197
200
198
201
void bindByKey (Key key, Function factory , List <Key > parameterKeys, [Visibility visibility]) {
199
202
if (visibility == null ) visibility = Visibility .CHILDREN ;
200
- int visibilityId = _toVisId (visibility);
203
+ int visibilityId = _toVisibilityId (visibility);
201
204
int keyVisId = key.uid;
202
205
if (keyVisId != visibilityId) {
203
206
if (keyVisId == null ) {
204
207
key.uid = visibilityId;
205
208
} else {
206
- throw "Can not set $visibility on $key , it alread has ${_toVis (keyVisId )}" ;
209
+ throw "Can not set $visibility on $key , it already has ${_toVisibility (keyVisId )}" ;
207
210
}
208
211
}
209
212
if (_key0 == null || identical (_key0, key)) { _key0 = key; _pKeys0 = parameterKeys; _factory0 = factory ; }
@@ -253,17 +256,17 @@ class DirectiveInjector implements DirectiveBinder {
253
256
}
254
257
}
255
258
256
- num _getDepth (int visType ) {
257
- switch (visType ) {
259
+ num _getDepth (int visibility ) {
260
+ switch (visibility ) {
258
261
case VISIBILITY_LOCAL : return 0 ;
259
262
case VISIBILITY_DIRECT_CHILD : return 1 ;
260
263
case VISIBILITY_CHILDREN : return _MAX_TREE_DEPTH ;
261
264
default : throw null ;
262
265
}
263
266
}
264
267
265
- _getDirectiveByKey (Key k, int visType , Injector appInjector) {
266
- num treeDepth = _getDepth (visType );
268
+ _getDirectiveByKey (Key k, int visibility , Injector appInjector) {
269
+ num treeDepth = _getDepth (visibility );
267
270
// ci stands for currentInjector, abbreviated for readability.
268
271
var ci = this ;
269
272
while (ci != null && treeDepth >= 0 ) {
@@ -379,7 +382,6 @@ class DirectiveInjector implements DirectiveBinder {
379
382
return obj;
380
383
}
381
384
382
-
383
385
ElementProbe get elementProbe {
384
386
if (_elementProbe == null ) {
385
387
ElementProbe parentProbe = _parent == null ? null : _parent.elementProbe;
@@ -472,7 +474,7 @@ class ComponentDirectiveInjector extends DirectiveInjector {
472
474
473
475
// Add 1 to visibility to allow to skip over current component injector.
474
476
// For example, a local directive is visible from its component injector children.
475
- num _getDepth (int visType ) => super ._getDepth (visType ) + 1 ;
477
+ num _getDepth (int visibility ) => super ._getDepth (visibility ) + 1 ;
476
478
}
477
479
478
480
0 commit comments