The problem is the condition if(i < ns-length - 1):
Instead of the last node being updated in case of a change, a new node is inserted at the end of the view.
The condition should be fixed to (i < ns.length).