mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -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) {
|
setName: function(name) {
|
||||||
|
// Empty name '' is stored as undefined internally
|
||||||
|
if ((name || '') === (this._name || ''))
|
||||||
|
return;
|
||||||
var children = this._parent._children,
|
var children = this._parent._children,
|
||||||
namedChildren = this._parent._namedChildren;
|
namedChildren = this._parent._namedChildren;
|
||||||
if (name != this._name) {
|
// If the item already had a name,
|
||||||
// If the item already had a name,
|
// remove its property from the parent's children object:
|
||||||
// remove its property from the parent's children object:
|
if (this._name)
|
||||||
if (this._name)
|
this._removeFromNamed();
|
||||||
this._removeFromNamed();
|
|
||||||
this._name = name || undefined;
|
|
||||||
}
|
|
||||||
if (name) {
|
if (name) {
|
||||||
(namedChildren[name] = namedChildren[name] || []).push(this);
|
(namedChildren[name] = namedChildren[name] || []).push(this);
|
||||||
children[name] = this;
|
children[name] = this;
|
||||||
} else {
|
} else if (this._name) {
|
||||||
delete children[name];
|
delete children[this._name];
|
||||||
}
|
}
|
||||||
|
this._name = name || undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue