brianmhunt / knockout-fast-foreach

Foreach. Faster. For Knockout.
MIT License
59 stars 18 forks source link

Fix to remove old items #9

Closed AdamWillden closed 9 years ago

AdamWillden commented 9 years ago

The item was being removed from the DOM meaning ptr.nextSibling returned null rather than the intended next sibling. Therefore we need to capture ptr.nextSibling before ptr is removed then apply it to ptr after.

There might well be a better way to organise the while loop but this fixes the issue at hand.

brianmhunt commented 9 years ago

Thanks Adam. The PR is definitely on the right track, but misses the case where there is one node in the template.

I'll write some tests, so we capture the issue you highlighted and the issues I've just mentioned.

Cheers

AdamWillden commented 9 years ago

Ah I see, that's what I get for only looking at one bit of code! At least this should clear things up for you to fix, cheers.