Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 36e35b2

Browse files
committed
perf(ngRepeat): optimize marking of nodes that are being removed via an animation
1 parent 13d113c commit 36e35b2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ng/directive/ngRepeat.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,18 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
366366
}
367367
}
368368

369-
// remove existing items
369+
// remove leftover items
370370
for (var blockKey in lastBlockMap) {
371371
block = lastBlockMap[blockKey];
372372
elementsToRemove = getBlockNodes(block.clone);
373373
$animate.leave(elementsToRemove);
374-
forEach(elementsToRemove, function (element) {
375-
element[NG_REMOVED] = true;
376-
});
374+
if (elementsToRemove[0].parent) {
375+
// if the element was not removed yet because of pending animation, mark it as deleted
376+
// so that we can ignore it later
377+
for (index = 0, length = elementsToRemove.length; index < length; index++) {
378+
elementsToRemove[index][NG_REMOVED] = true;
379+
}
380+
}
377381
block.scope.$destroy();
378382
}
379383

0 commit comments

Comments
 (0)