mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Fix a bug in Item#_removeNamed() for items without parents.
Closes #490.
This commit is contained in:
parent
04a0c995bc
commit
56704b9206
1 changed files with 22 additions and 19 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue