expect(wrapperChildren[2].getText()).to.equal(' cat');
});
});
+
+ describe('unwrapping', function() {
+ it('unwraps DocumentTextElement from its parent DocumentNodeElement if it\'s its only child', function() {
+ var c = canvas.fromXML('<section><div>Alice has a cat</div></section>'),
+ section = c.doc(),
+ text = section.children()[0].children()[0];
+
+ text.unwrap();
+
+ expect(section.children().length).to.equal(1);
+ expect(section.children()[0].getText()).to.equal('Alice has a cat');
+ })
+ });
});
describe('Lists api', function() {
return DocumentElement.prototype.wrapWithNodeElement.call(this, wlxmlNode);
}
},
+ unwrap: function() {
+ if(this.parent().children().length === 1) {
+ var parent = this.parent();
+ parent.after(this);
+ parent.detach();
+ }
+ },
split: function(params) {
var parentElement = this.parent(),
myIdx = parentElement.childIndex(this),