Add Item#removeChildren() and #setChildren().

This commit is contained in:
Jürg Lehni 2011-05-16 19:34:57 +01:00
parent 00b5f6a6bb
commit 75b0fa3596

View file

@ -239,7 +239,12 @@ var Item = this.Item = Base.extend({
return this._children;
},
// TODO: #setChildren()
setChildren: function(children) {
this.removeChildren();
for (var i = 0, l = children && children.length; i < l; i++)
this.appendBottom(children[i]);
},
/**
* Reverses the order of this item's children
@ -253,6 +258,18 @@ var Item = this.Item = Base.extend({
}
},
/**
* Removes all of the item's children, if it has any
*/
removeChildren: function() {
var removed = false;
if (this._children) {
for (var i = this._children.length; i >= 0 i--)
removed = this._children[i].remove() || removed;
}
return removed;
},
/**
* The first item contained within this item.
*/