Elements are not removed when using containerless templates #505

unionsquare opened this Issue May 31, 2012 · 2 comments


None yet
2 participants

When using containerless templates as bellow within a foreach binding we have found that template nodes are not removed when the item is removed.

<!-- ko template:{name:VM.templates.templateName, foreach:controls} --> <!-- /ko --> 

We have identified the following code to be causing the issue:
in knockout2.1.0.debug.js line 3190:

if (contiguousNodeArray.length > 2)

when you have the template above the length is two and the nodes above get removed but none of the inner template nodes are removed, we have found that the following code has solved this problem however we are submitting this for your review.

if (contiguousNodeArray.length > 2 || (contiguousNodeArray.length == 2 && (contiguousNodeArray[0].nodeType == 8 && contiguousNodeArray[0].nodeType == 8))) {

mbest commented May 31, 2012

Take a look at 3ec0059 to see how I fixed this problem. This fix is attached to issue #144.


mbest commented Jun 7, 2012

This was fixed in #144.

mbest closed this Jun 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment