idx = parentContents.index(this),
next = idx < parentContents.length - 1 ? parentContents[idx+1] : null;
- var addInfo = function() {
+ var addInfo = function(toAdd) {
if(next) {
- $(next).data('orig-before', oldText);
+ $(next).data('orig-before', toAdd);
} else {
- parent.data('orig-append', oldText);
+ parent.data('orig-append', toAdd);
}
}
+ (endSpace && (spanParent || spanAfter) ? ' ' : '');
if(newText !== oldText) {
this.data = newText;
- addInfo();
+ if(endSpace) {
+ var toAdd = oldText.match(/\s+$/g)[0];
+ if(newText[newText.length - 1] === ' ' && toAdd[0] === ' ')
+ toAdd = toAdd.substr(1);
+ addInfo(toAdd);
+ }
}
} else {
if(this.data.length === 0 && oldLength > 0 && el.parent().contents().length === 1)
this.data = ' ';
if(this.data.length === 0) {
- addInfo();
+ addInfo(oldText);
el.remove();
return true; // continue
expect(xmlOut).to.equal('<section><span></span></section>');
});
+ it('keeps original white space at the end of text', function() {
+
+ var xmlIn = '<header>Some text ended with white space \
+ \
+ <span class="uri">Some text</span> some text\
+ \
+ </header>',
+ c = canvas.fromXML(xmlIn);
+
+ var xmlOut = c.toXML();
+ console.log(xmlOut);
+ expect(xmlOut).to.equal(xmlIn);
+
+ });
+
})
})
});