expect(xmlOut).to.equal(xmlIn);
});
+ it('keeps white space after detaching text element', function() {
+ var xmlIn = '<section><header>header</header>\
+ \
+ text1\
+ \
+ </section>',
+ expectedXmlOut = '<section><header>header</header>\
+ \
+ \
+ \
+ </section>',
+ c = canvas.fromXML(xmlIn),
+ children = c.doc().children(),
+ text = children[children.length-1];
+
+ expect(text.getText()).to.equal('text1');
+
+ text.detach();
+
+ var xmlOut = c.toXML();
+ expect(xmlOut).to.equal(expectedXmlOut);
+ });
+
})
})
});
for(var i = children.length - 1; i >= 0; i--) {
childParts = children[i].toXML(level + 1);
- if(containsPrefixAndSuffix(i)) {
+ if(containsPrefixAndSuffix(i) && children[i] instanceof DocumentTextElement) {
$(node.contents()[0]).after(childParts);
} else {
node.prepend(childParts);