Insert results of boolean operations above whichever of the two paths appear further up in the stack.

This commit is contained in:
Jürg Lehni 2015-08-30 14:47:46 +02:00
parent b4755ea699
commit 31771aa01d
2 changed files with 15 additions and 1 deletions

View file

@ -2664,6 +2664,16 @@ var Item = Base.extend(Emitter, /** @lends Item# */{
return item ? item.isDescendant(this) : false;
},
/**
* Checks if the item is an a sibling of the specified item.
*
* @param {Item} item the item to check against
* @return {Boolean} {@true if the item is aa sibling of the specified item}
*/
isSibling: function(item) {
return this._parent === item._parent;
},
/**
* Checks whether the item is grouped with the specified item.
*

View file

@ -216,7 +216,11 @@ PathItem.inject(new function() {
true);
// See if the CompoundPath can be reduced to just a simple Path.
result = result.reduce();
result.insertAbove(path1);
// Insert the resulting path above whichever of the two paths appear
// further up in the stack.
result.insertAbove(path2 && path1.isSibling(path2)
&& path1.getIndex() < path2.getIndex()
? path2 : path1);
// Copy over the left-hand item's style and we're done.
// TODO: Consider using Item#_clone() for this, but find a way to not
// clone children / name (content).