Skip to content

Commit

Permalink
Adding a removeChildren method
Browse files Browse the repository at this point in the history
- Remove all children, removing the name references and index
- This method calls removeFromParent on the children so it leaves it up to the child to remove itself in whatever way it needs to. IE: DataView's also remove their DOM.
  • Loading branch information
Timm Michaud committed Apr 2, 2013
1 parent 657e3a3 commit 395a50b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions build/debug/sudo-x.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ sudo.Container.prototype.removeChild = function removeChild(arg) {
return this;
};

// ###removeAllChildren
// ###removeChildren
// Remove all children, removing the name references and index
// This method calls removeFromParent on the children so it also removes the child's DOM.
// This method calls removeFromParent on each child. If it's a DataView also removes the child's DOM.
// `returns` {Object} `this`
sudo.Container.prototype.removeAllChildren = function removeAllChildren(arg) {
while(this.children.length > 0) {
this.children[0].removeFromParent();
sudo.Container.prototype.removeChildren = function removeChildren(arg) {
while(this.children.length) {
this.children.shift().removeFromParent();
}
return this;
};
Expand Down
10 changes: 5 additions & 5 deletions container/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ sudo.Container.prototype.removeChild = function removeChild(arg) {
return this;
};

// ###removeAllChildren
// ###removeChildren
// Remove all children, removing the name references and index
// This method calls removeFromParent on the children so it also removes the child's DOM.
// This method calls removeFromParent on each child. If it's a DataView also removes the child's DOM.
// `returns` {Object} `this`
sudo.Container.prototype.removeAllChildren = function removeAllChildren(arg) {
while(this.children.length > 0) {
this.children[0].removeFromParent();
sudo.Container.prototype.removeChildren = function removeChildren(arg) {
while(this.children.length) {
this.children.shift().removeFromParent();
}
return this;
};
Expand Down
2 changes: 1 addition & 1 deletion container/spec/container.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Sudo Container Class', function() {
it('Removes all children', function() {
container.addChild(child1, 'Galahad').addChild(child2, 'Robin');
expect(container.children.length).toBe(2);
container.removeAllChildren();
container.removeChildren();
expect(container.children.length).toBe(0);
});

Expand Down

0 comments on commit 395a50b

Please sign in to comment.