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

Commit b5714ce

Browse files
committed
refactor(ngRepeat): simplify previousNode boundary calculation
the previousNode was almost always correct except when we added a new block in which case incorrectly assigned the cloned collection to the variable instead of the end comment node.
1 parent 27d4a4f commit b5714ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ng/directive/ngRepeat.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
387387
key = (collection === collectionKeys) ? index : collectionKeys[index];
388388
value = collection[key];
389389
block = nextBlockOrder[index];
390-
if (nextBlockOrder[index - 1]) previousNode = getBlockEnd(nextBlockOrder[index - 1]);
391390

392391
if (block.scope) {
393392
// if we have already seen this object, then we need to reuse the
@@ -411,9 +410,10 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
411410
$transclude(function ngRepeatTransclude(clone, scope) {
412411
block.scope = scope;
413412
// http://jsperf.com/clone-vs-createcomment
414-
clone[clone.length++] = ngRepeatEndComment.cloneNode();
413+
var endNode = ngRepeatEndComment.cloneNode();
414+
clone[clone.length++] = endNode;
415415
$animate.enter(clone, null, jqLite(previousNode));
416-
previousNode = clone;
416+
previousNode = endNode;
417417
// Note: We only need the first/last node of the cloned nodes.
418418
// However, we need to keep the reference to the jqlite wrapper as it might be changed later
419419
// by a directive with templateUrl when its template arrives.

0 commit comments

Comments
 (0)