Skip to content

Commit 1dcea62

Browse files
author
Przemek Kaminski
committed
ngRepeat: insert end comment only after last element, not after each iterated item
This caused a subtle bug in angular-sortable directive: when moving elements between lists, previousNode was a comment, which doesn't have the .parentNode attribute so the $animate.enter function tried to call insertBefore of a null. Moreover, it looks bad that 'end ngRepeat' comment appears after every iterated node, it should be just at the end of the repeat block.
1 parent 727b232 commit 1dcea62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ng/directive/ngRepeat.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
379379

380380
if (!block.startNode) {
381381
linker(childScope, function(clone) {
382-
clone[clone.length++] = document.createComment(' end ngRepeat: ' + expression + ' ');
382+
if(childScope.$last) {
383+
clone[clone.length++] = document.createComment(' end ngRepeat: ' + expression + ' ');
384+
}
383385
$animate.enter(clone, null, jqLite(previousNode));
384386
previousNode = clone;
385387
block.scope = childScope;

0 commit comments

Comments
 (0)