Accept CompoundPath items as children of CompoundPath items.

Just add their children and remove the parent.

Closes #541
This commit is contained in:
Jürg Lehni 2015-09-13 16:06:24 +02:00
parent e2d2c836e5
commit b231e9b2a8

View file

@ -102,6 +102,16 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
},
insertChildren: function insertChildren(index, items, _preserve) {
// Convert CompoundPath items in the children list by adding their
// children to the list and removing their parent.
var before = items.slice();
for (var i = items.length - 1; i >= 0; i--) {
var item = items[i];
if (item instanceof CompoundPath) {
items.splice.apply(items, [i, 1].concat(item.removeChildren()));
item.remove();
}
}
// Pass on 'path' for _type, to make sure that only paths are added as
// children.
items = insertChildren.base.call(this, index, items, _preserve, Path);