From b5714ce1dfca743733e84431161fc888fdcad24a Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 12 Aug 2014 23:46:25 -0700 Subject: [PATCH] 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. --- src/ng/directive/ngRepeat.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index b5982692..1d7d516f 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -387,7 +387,6 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { key = (collection === collectionKeys) ? index : collectionKeys[index]; value = collection[key]; block = nextBlockOrder[index]; - if (nextBlockOrder[index - 1]) previousNode = getBlockEnd(nextBlockOrder[index - 1]); if (block.scope) { // if we have already seen this object, then we need to reuse the @@ -411,9 +410,10 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { $transclude(function ngRepeatTransclude(clone, scope) { block.scope = scope; // http://jsperf.com/clone-vs-createcomment - clone[clone.length++] = ngRepeatEndComment.cloneNode(); + var endNode = ngRepeatEndComment.cloneNode(); + clone[clone.length++] = endNode; $animate.enter(clone, null, jqLite(previousNode)); - previousNode = clone; + previousNode = endNode; // Note: We only need the first/last node of the cloned nodes. // However, we need to keep the reference to the jqlite wrapper as it might be changed later // by a directive with templateUrl when its template arrives.