Loading ...
Sorry, an error occurred while loading the content.

bug with TreeView removeNode method?

Expand Messages
  • thirteenth_monster
    it looks to me like there s a bug when you re removing a node that has children. removeNode() calls _deleteNode(), which calls removeChildren() removeChildren
    Message 1 of 1 , May 31, 2006
    View Source
    • 0 Attachment
      it looks to me like there's a bug when you're removing a node that has
      children.

      removeNode() calls _deleteNode(), which calls removeChildren()

      removeChildren iterates over the child collection, from the 0 index up
      to the collection length, removing them one at a time. It looks like
      this causes the indexes to change as you're iterating over them, so it
      gets halfway through then blows up with a null reference.

      Making it loop in reverse order seems to work:

      I changed this line:
      for (var i=0, len=node.children.length;i<len;++i)

      to this:
      for (var i=node.children.length-1;i>=0;i--)

      and it's working for me now..
    Your message has been successfully submitted and would be delivered to recipients shortly.