From 2f6fbcba74b0dcd7710a7bc4847995cd5abaaa5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 7 May 2011 14:34:57 +0100 Subject: [PATCH] Check result from removeFromParent(). --- src/item/Item.js | 3 +-- src/item/Layer.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 015a7cb1..e3684864 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -804,8 +804,7 @@ var Item = this.Item = Base.extend({ function append(top) { return function(item) { - if (this.children) { - item.removeFromParent(); + if (this.children && item.removeFromParent()) { this.children.splice(top ? this.children.length : 0, 0, item); // TODO: Reassign _index item.parent = this; diff --git a/src/item/Layer.js b/src/item/Layer.js index 846a85df..271c1c5b 100644 --- a/src/item/Layer.js +++ b/src/item/Layer.js @@ -57,8 +57,8 @@ var Layer = this.Layer = Group.extend({ function move(above) { return function(item) { // if the item is a layer and contained within Document#layers - if (item instanceof Layer && !item.parent) { - this.removeFromParent(); + if (item instanceof Layer && !item.parent + && this.removeFromParent()) { item._document.layers.splice(item.getIndex() + (above ? 1 : -1), 0, this); this.setDocument(item._document);