mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix #1009: Make sure all name lookup structures are kept in sync for layers too.
This commit is contained in:
parent
d52a6f3107
commit
ca76c1d24f
2 changed files with 10 additions and 4 deletions
|
@ -2352,13 +2352,14 @@ new function() { // Injection scope for hit-test functions shared with project
|
|||
// See #_remove() for an explanation of this:
|
||||
notifySelf = project && project._changes;
|
||||
for (var i = 0, l = items.length; i < l; i++) {
|
||||
var item = items[i];
|
||||
var item = items[i],
|
||||
name = item._name;
|
||||
item._parent = this;
|
||||
item._setProject(this._project, true);
|
||||
// Setting the name again makes sure all name lookup structures
|
||||
// Set the name again to make sure all name lookup structures
|
||||
// are kept in sync.
|
||||
if (item._name)
|
||||
item.setName(item._name);
|
||||
if (name)
|
||||
item.setName(name);
|
||||
if (notifySelf)
|
||||
this._changed(/*#=*/Change.INSERTION);
|
||||
}
|
||||
|
|
|
@ -355,6 +355,11 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
layer._remove(false, true);
|
||||
Base.splice(this._children, [layer], index, 0);
|
||||
layer._setProject(this, true);
|
||||
// Set the name again to make sure all name lookup structures
|
||||
// are kept in sync.
|
||||
var name = layer._name;
|
||||
if (name)
|
||||
layer.setName(name);
|
||||
// See Item#_remove() for an explanation of this:
|
||||
if (this._changes)
|
||||
layer._changed(/*#=*/Change.INSERTION);
|
||||
|
|
Loading…
Reference in a new issue