Fix a bug in Item#_removeNamed() for items without parents.

Closes #490.
This commit is contained in:
Jürg Lehni 2014-07-25 21:08:14 +02:00
parent 04a0c995bc
commit 56704b9206

View file

@ -2183,13 +2183,14 @@ var Item = Base.extend(Callback, /** @lends Item# */{
* Removes the item from its parent's named children list.
*/
_removeNamed: function() {
var children = this._parent._children,
namedChildren = this._parent._namedChildren,
var parent = this._parent;
if (parent) {
var children = parent._children,
namedChildren = parent._namedChildren,
name = this._name,
namedArray = namedChildren[name],
index = namedArray ? namedArray.indexOf(this) : -1;
if (index == -1)
return;
if (index !== -1) {
// Remove the named reference
if (children[name] == this)
delete children[name];
@ -2203,6 +2204,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
// Otherwise delete the empty array
delete namedChildren[name];
}
}
}
},
/**