From: Aleksander Ɓukasz Date: Thu, 25 Jul 2013 08:02:26 +0000 (+0200) Subject: Fixing xml output - entities X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/11780e28b30ed57653769d67d9d523925d316973 Fixing xml output - entities --- diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index eeab1b2..565e4b0 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -1122,6 +1122,21 @@ describe('Canvas', function() { expect($(c.toXML()).attr('meta-uri')).to.equal(undefined, 'setting attribute to zero length string'); }); + describe('output xml', function() { + it('keeps entities intact', function() { + var xmlIn = '
< >
', + c = canvas.fromXML(xmlIn), + xmlOut = c.toXML(); + expect(xmlOut).to.equal(xmlIn); + }); + it('keeps entities intact when they form html/xml', function() { + var xmlIn = '
<abc>
', + c = canvas.fromXML(xmlIn), + xmlOut = c.toXML(); + expect(xmlOut).to.equal(xmlIn); + }); + }); + describe('formatting output xml', function() { /*it('keeps white spaces at the edges of input xml', function() { var xmlIn = '
', diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 8ef918a..29b07df 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -210,7 +210,9 @@ $.extend(DocumentNodeElement.prototype, { for(var i = children.length - 1; i >= 0; i--) { childParts = children[i].toXML(level + 1); - + if(typeof childParts === 'string') + childParts = [document.createTextNode(childParts)]; + if(containsPrefixAndSuffix(i) && children[i] instanceof DocumentTextElement) { $(node.contents()[0]).after(childParts); } else {