mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-16 10:23:51 +08:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user