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