@@ -9,17 +9,17 @@ class Compiler {
9
9
Compiler (this ._perf, this ._parser, this ._expando);
10
10
11
11
_compileBlock (NodeCursor domCursor, NodeCursor templateCursor,
12
- List <DirectiveRef > useExistingDirectiveRefs ,
12
+ List <DirectiveRef > existingDirectiveRefs ,
13
13
DirectiveMap directives) {
14
- if (domCursor.nodeList ().length == 0 ) return null ;
14
+ if (domCursor.current == null ) return null ;
15
15
16
16
var directivePositions = null ; // don't pre-create to create sparse tree and prevent GC pressure.
17
17
var cursorAlreadyAdvanced;
18
18
19
19
do {
20
- var declaredDirectiveRefs = useExistingDirectiveRefs == null
21
- ? directives.selector (domCursor.nodeList ()[ 0 ] )
22
- : useExistingDirectiveRefs ;
20
+ var declaredDirectiveRefs = existingDirectiveRefs == null
21
+ ? directives.selector (domCursor.current )
22
+ : existingDirectiveRefs ;
23
23
var children = NgAnnotation .COMPILE_CHILDREN ;
24
24
var childDirectivePositions = null ;
25
25
List <DirectiveRef > usableDirectiveRefs = null ;
@@ -73,7 +73,7 @@ class Compiler {
73
73
..add (usableDirectiveRefs)
74
74
..add (childDirectivePositions);
75
75
}
76
- } while (templateCursor.microNext () && domCursor.microNext ());
76
+ } while (templateCursor.moveNext () && domCursor.moveNext ());
77
77
78
78
return directivePositions;
79
79
}
@@ -83,27 +83,28 @@ class Compiler {
83
83
DirectiveRef directiveRef,
84
84
List <DirectiveRef > transcludedDirectiveRefs,
85
85
DirectiveMap directives) {
86
- var anchorName = directiveRef.annotation.selector + (directiveRef.value != null ? '=' + directiveRef.value : '' );
86
+ var anchorName = directiveRef.annotation.selector +
87
+ (directiveRef.value != null ? '=' + directiveRef.value : '' );
87
88
var blockFactory;
88
89
var blocks;
89
90
90
91
var transcludeCursor = templateCursor.replaceWithAnchor (anchorName);
91
92
var domCursorIndex = domCursor.index;
92
93
var directivePositions =
93
- _compileBlock (domCursor, transcludeCursor, transcludedDirectiveRefs, directives);
94
+ _compileBlock (domCursor, transcludeCursor, transcludedDirectiveRefs,
95
+ directives);
94
96
if (directivePositions == null ) directivePositions = [];
95
97
96
- blockFactory = new BlockFactory (transcludeCursor.elements, directivePositions, _perf, _expando);
98
+ blockFactory = new BlockFactory (transcludeCursor.elements,
99
+ directivePositions, _perf, _expando);
97
100
domCursor.index = domCursorIndex;
98
101
99
- if (domCursor.isInstance () ) {
102
+ if (domCursor.isInstance) {
100
103
domCursor.insertAnchorBefore (anchorName);
101
- blocks = [blockFactory (domCursor.nodeList ())];
102
- domCursor.macroNext ();
103
- templateCursor.macroNext ();
104
- while (domCursor.isValid () && domCursor.isInstance ()) {
105
- blocks.add (blockFactory (domCursor.nodeList ()));
106
- domCursor.macroNext ();
104
+ blocks = [blockFactory ([domCursor.current])];
105
+ templateCursor.moveNext ();
106
+ while (domCursor.moveNext () && domCursor.isInstance) {
107
+ blocks.add (blockFactory ([domCursor.current]));
107
108
templateCursor.remove ();
108
109
}
109
110
} else {
@@ -116,8 +117,8 @@ class Compiler {
116
117
BlockFactory call (List <dom.Node > elements, DirectiveMap directives) {
117
118
var timerId;
118
119
assert ((timerId = _perf.startTimer ('ng.compile' , _html (elements))) != false );
119
- List <dom. Node > domElements = elements;
120
- List <dom. Node > templateElements = cloneElements (domElements);
120
+ final domElements = elements;
121
+ final templateElements = cloneElements (domElements);
121
122
var directivePositions = _compileBlock (
122
123
new NodeCursor (domElements), new NodeCursor (templateElements),
123
124
null , directives);
@@ -144,20 +145,23 @@ class Compiler {
144
145
String dstExpression = dstPath.isEmpty ? attrName : dstPath;
145
146
Expression dstPathFn = _parser (dstExpression);
146
147
if (! dstPathFn.isAssignable) {
147
- throw "Expression '$dstPath ' is not assignable in mapping '$mapping ' for attribute '$attrName '." ;
148
+ throw "Expression '$dstPath ' is not assignable in mapping '$mapping ' "
149
+ "for attribute '$attrName '." ;
148
150
}
149
151
ApplyMapping mappingFn;
150
152
switch (mode) {
151
153
case '@' :
152
- mappingFn = (NodeAttrs attrs, Scope scope, Object controller, FilterMap filters, notify ()) {
154
+ mappingFn = (NodeAttrs attrs, Scope scope, Object controller,
155
+ FilterMap filters, notify ()) {
153
156
attrs.observe (attrName, (value) {
154
157
dstPathFn.assign (controller, value);
155
158
notify ();
156
159
});
157
160
};
158
161
break ;
159
162
case '<=>' :
160
- mappingFn = (NodeAttrs attrs, Scope scope, Object controller, FilterMap filters, notify ()) {
163
+ mappingFn = (NodeAttrs attrs, Scope scope, Object controller,
164
+ FilterMap filters, notify ()) {
161
165
if (attrs[attrName] == null ) return notify ();
162
166
String expression = attrs[attrName];
163
167
Expression expressionFn = _parser (expression);
@@ -194,7 +198,8 @@ class Compiler {
194
198
};
195
199
break ;
196
200
case '=>' :
197
- mappingFn = (NodeAttrs attrs, Scope scope, Object controller, FilterMap filters, notify ()) {
201
+ mappingFn = (NodeAttrs attrs, Scope scope, Object controller,
202
+ FilterMap filters, notify ()) {
198
203
if (attrs[attrName] == null ) return notify ();
199
204
Expression attrExprFn = _parser (attrs[attrName]);
200
205
var shadowValue = null ;
@@ -207,7 +212,8 @@ class Compiler {
207
212
};
208
213
break ;
209
214
case '=>!' :
210
- mappingFn = (NodeAttrs attrs, Scope scope, Object controller, FilterMap filters, notify ()) {
215
+ mappingFn = (NodeAttrs attrs, Scope scope, Object controller,
216
+ FilterMap filters, notify ()) {
211
217
if (attrs[attrName] == null ) return notify ();
212
218
Expression attrExprFn = _parser (attrs[attrName]);
213
219
var watch;
@@ -223,8 +229,10 @@ class Compiler {
223
229
};
224
230
break ;
225
231
case '&' :
226
- mappingFn = (NodeAttrs attrs, Scope scope, Object dst, FilterMap filters, notify ()) {
227
- dstPathFn.assign (dst, _parser (attrs[attrName]).bind (scope.context, ScopeLocals .wrapper));
232
+ mappingFn = (NodeAttrs attrs, Scope scope, Object dst,
233
+ FilterMap filters, notify ()) {
234
+ dstPathFn.assign (dst, _parser (attrs[attrName])
235
+ .bind (scope.context, ScopeLocals .wrapper));
228
236
notify ();
229
237
};
230
238
break ;
0 commit comments