mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Fix a bug where after renaming items, old name references where still laying around.
This commit is contained in:
parent
5f48d4e4a9
commit
30087d046a
1 changed files with 10 additions and 9 deletions
|
@ -85,21 +85,22 @@ var Item = this.Item = Base.extend({
|
|||
},
|
||||
|
||||
setName: function(name) {
|
||||
// Empty name '' is stored as undefined internally
|
||||
if ((name || '') === (this._name || ''))
|
||||
return;
|
||||
var children = this._parent._children,
|
||||
namedChildren = this._parent._namedChildren;
|
||||
if (name != this._name) {
|
||||
// If the item already had a name,
|
||||
// remove its property from the parent's children object:
|
||||
if (this._name)
|
||||
this._removeFromNamed();
|
||||
this._name = name || undefined;
|
||||
}
|
||||
// If the item already had a name,
|
||||
// remove its property from the parent's children object:
|
||||
if (this._name)
|
||||
this._removeFromNamed();
|
||||
if (name) {
|
||||
(namedChildren[name] = namedChildren[name] || []).push(this);
|
||||
children[name] = this;
|
||||
} else {
|
||||
delete children[name];
|
||||
} else if (this._name) {
|
||||
delete children[this._name];
|
||||
}
|
||||
this._name = name || undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue