From 11780e28b30ed57653769d67d9d523925d316973 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 25 Jul 2013 10:02:26 +0200 Subject: [PATCH] Fixing xml output - entities --- modules/documentCanvas/canvas/canvas.test3.js | 15 +++++++++++++++ modules/documentCanvas/canvas/documentElement.js | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 { -- 2.20.1