mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix CompoundPath#insertChildren() when passing children lists from otheer items.
This commit is contained in:
parent
82de56ea2c
commit
1ae95999d5
1 changed files with 4 additions and 1 deletions
|
@ -108,10 +108,13 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
|
||||||
|
|
||||||
insertChildren: function insertChildren(index, items, _preserve) {
|
insertChildren: function insertChildren(index, items, _preserve) {
|
||||||
// Convert CompoundPath items in the children list by adding their
|
// Convert CompoundPath items in the children list by adding their
|
||||||
// children to the list and removing their parent.
|
// children to the list, replacing their parent.
|
||||||
for (var i = items.length - 1; i >= 0; i--) {
|
for (var i = items.length - 1; i >= 0; i--) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
if (item instanceof CompoundPath) {
|
if (item instanceof CompoundPath) {
|
||||||
|
// Clone the items array before modifying it, as it may be a
|
||||||
|
// passed children array from another item.
|
||||||
|
items = items.slice();
|
||||||
items.splice.apply(items, [i, 1].concat(item.removeChildren()));
|
items.splice.apply(items, [i, 1].concat(item.removeChildren()));
|
||||||
item.remove();
|
item.remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue