Skip to content

Instantly share code, notes, and snippets.

@mikechambers
Created March 19, 2011 19:30
Show Gist options
  • Save mikechambers/877734 to your computer and use it in GitHub Desktop.
Save mikechambers/877734 to your computer and use it in GitHub Desktop.
Recursive Call for Clearing Nested nodes
BoundsNode.prototype.clear = function()
{
this._stuckCount = 0;
//array
this.children.length = 0;
var len = this.nodes.length;
if(!len)
{
return;
}
for(var i = 0; i < len; i++)
{
this.nodes[i].clear();
}
//array
this.nodes.length = 0;
//call the hidden super.clear, and make sure its called with this = this instance
//Object.getPrototypeOf(BoundsNode.prototype).clear.call(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment