From b231e9b2a84762941edfd5ed00d23377dcd8acf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 13 Sep 2015 16:06:24 +0200 Subject: [PATCH] Accept CompoundPath items as children of CompoundPath items. Just add their children and remove the parent. Closes #541 --- src/path/CompoundPath.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 343eacab..69c2df01 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -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);