section = c.doc(),
text = section.children()[1].children()[0];
- text.unwrap();
+ var newTextContainer = text.unwrap();
expect(section.children().length).to.equal(1, 'section has one child');
expect(section.children()[0].getText()).to.equal('Alice has a cat');
+ expect(newTextContainer.sameNode(c.doc())).to.equal(true, 'unwrap returns new text parent DocumentNodeElement');
})
});
});
}
},
unwrap: function() {
- var parent = this.parent();
+ var parent = this.parent(),
+ toret;
if(parent.children().length === 1) {
+ toret = parent.parent();
var grandParent = parent.parent();
if(grandParent) {
var grandParentChildren = grandParent.children(),
parent.after(this);
}
parent.detach();
+ return toret;
}
},
split: function(params) {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {
this.canvas.list.extractItems({element1: parent1, element2: parent2});
} else if(!cursor.isSelecting()) {
- cursor.getPosition().element.unwrap();
+ var toUnwrap = cursor.getPosition().element,
+ parent = toUnwrap.unwrap();
+ this.canvas.setCurrentElement(parent);
}
} else if(command === 'wrap-node') {
if(this.canvas.list.areItemsOfTheSameList({element1: parent1, element2: parent2})) {