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');
});
+
+ it('unwraps text element from its parent - first child case', function() {
+ var c = canvas.fromXML('<section><span class="uri">Some</span>text</section>'),
+ section = c.doc(),
+ span = section.children()[0];
+
+ span.children()[0].unwrap();
+
+ var sectionChildren = section.children();
+
+ expect(sectionChildren).to.have.length(1);
+ expect(sectionChildren[0].getText()).to.equal('Sometext');
+ });
});
});
prev.setText(prev.getText() + this.getText() + next.getText());
next.detach();
} else if (prev || next) {
- var target = prev ? prev : next;
- target.setText(target.getText() + this.getText());
+ var target = prev ? prev : next,
+ newText = prev ? target.getText() + this.getText() : this.getText() + target.getText();
+ target.setText(newText);
} else {
parent.after(this);
}