Check result from removeFromParent().

This commit is contained in:
Jürg Lehni 2011-05-07 14:34:57 +01:00
parent 59e2783979
commit 2f6fbcba74
2 changed files with 3 additions and 4 deletions

View file

@ -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;

View file

@ -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);