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.
This commit is contained in:
Igor Minar
2014-08-12 23:46:25 -07:00
parent 27d4a4f0ca
commit b5714ce1df

View File

@@ -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.