Browse files

#440 - fix problem in 2.1 that foreach doesn't update correctly if fi…

…rst item in rewritten template has a binding

This doesn't fix the core problem that the comment left over from memoization stays in the list of nodes that foreach tracks. But since this change makes 2.1 behave more like 2.0, it's probably sufficient.
  • Loading branch information...
1 parent f4a861a commit 587fa014317d20fa09a371ed58762daa38e6649e @mbest mbest committed Apr 23, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/binding/editDetection/arrayToDomNodeChildren.js
View
8 src/binding/editDetection/arrayToDomNodeChildren.js
@@ -151,10 +151,10 @@
}
}
if (!invokedBeforeRemoveCallback && nodesToDelete.length) {
- var commonParent = nodesToDelete[0].element.parentNode;
- if (commonParent) {
- for (var i = 0; i < nodesToDelete.length; i++)
- commonParent.removeChild(nodesToDelete[i].element);
+ for (var i = 0; i < nodesToDelete.length; i++) {
+ var element = nodesToDelete[i].element;
+ if (element.parentNode)
+ element.parentNode.removeChild(element);
}
}

0 comments on commit 587fa01

Please sign in to comment.