marcelklehr / buzzmap

draw and edit mindmaps interactively, using force-directed layouts (jQuery plugin)
marcelklehr.github.com/buzzmap
Other
22 stars 17 forks source link

Node.prototype.removeNode fix #3

Closed vishalpai closed 11 years ago

vishalpai commented 11 years ago

Hi,

Steps to reproduce the simplest use case:

  1. Create a node with value say 'Mathematics'
  2. Create a child node with value 20
  3. Add two grand children to the child node created in point number 2.
    • One grandchild with value 14
    • Second grandchild with value 6
  4. Expand the node created in point number 2.
  5. Remove the node with value 20. i.e. the one created in point number 2 i.e. same as the node expanded in point 4.
  6. Node with value 6 is not deleted.

Problem code in the function Node.prototype.removeNode = function ():

// remove all children
for (var i=0;i<this.children.length;i++)
{
    this.children[i].removeNode();
}

Fix:

// remove all children
while(this.children.length > 0)
{
    this.children[0].removeNode();
} 

Best Regards, Vishal

marcelklehr commented 11 years ago

Oh, right. That's doomed to fail.