@@ -87,8 +87,7 @@ class NgRepeat {
87
87
Function _generateId = (key, value, index) => value;
88
88
Watch _watch;
89
89
90
- NgRepeat (this ._viewPort, this ._boundViewFactory, this ._scope,
91
- this ._parser, this .formatters);
90
+ NgRepeat (this ._viewPort, this ._boundViewFactory, this ._scope, this ._parser, this .formatters);
92
91
93
92
set expression (value) {
94
93
assert (value != null );
@@ -154,6 +153,9 @@ class NgRepeat {
154
153
final changeFunctions = new List <Function >(length);
155
154
final removedIndexes = < int > [];
156
155
final int domLength = _rows == null ? 0 : _rows.length;
156
+ // DOM indexes of the former rows not yet handled in the
157
+ // They are stored in reverse order to simplify the code in removeFn which is called with
158
+ // indexes in ascending order
157
159
final leftInDom = new List .generate (domLength, (i) => domLength - 1 - i);
158
160
var domIndex;
159
161
@@ -220,9 +222,14 @@ class NgRepeat {
220
222
var changeFn = changeFunctions[targetIndex];
221
223
if (changeFn == null ) {
222
224
rows[targetIndex] = _rows[targetIndex];
223
- domIndex-- ;
224
225
// The element has not moved but `$last` and `$middle` might still need
225
226
// to be updated
227
+ var childContext = _updateContext (rows[targetIndex].scope.context, targetIndex, length);
228
+ if (domIndex < 0 || leftInDom[domIndex] != targetIndex) {
229
+ _viewPort.move (rows[targetIndex].view, moveAfter: previousView);
230
+ leftInDom.remove (targetIndex);
231
+ }
232
+ domIndex-- ;
226
233
_updateContext (rows[targetIndex].scope.context, targetIndex, length);
227
234
} else {
228
235
changeFn (targetIndex, previousView);
0 commit comments