From 61143e615dfb903cd11c11539b7259cc4bc8b9fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 18 Jul 2013 15:19:52 +0200 Subject: [PATCH 1/1] Don't serialize wlxml meta attribute if it's empty --- modules/documentCanvas/canvas/canvas.test3.js | 11 +++++++++++ modules/documentCanvas/canvas/documentElement.js | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 76ece55..2017a8a 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -1108,7 +1108,18 @@ describe('Canvas', function() { expect($xmlOut.attr('a')).to.equal('1'); expect($xmlOut.attr('xmlns:dcterms')).to.equal('http://purl.org/dc/terms/'); + }); + + it('doesn\' serialize meta attribute if its empty', function() { + var c; + + c = canvas.fromXML('
'); + c.doc().setWlxmlMetaAttr('uri', ''); + expect($(c.toXML()).attr('meta-uri')).to.equal(undefined, 'overriding attribute with zero length string'); + c = canvas.fromXML('
'); + c.doc().setWlxmlMetaAttr('uri', ''); + expect($(c.toXML()).attr('meta-uri')).to.equal(undefined, 'setting attribute to zero length string'); }); describe('formatting output xml', function() { diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 9c2749e..94b8422 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -163,7 +163,8 @@ $.extend(DocumentNodeElement.prototype, { node.attr('class', this.getWlxmlClass()); var meta = this.getWlxmlMetaAttrs(); meta.forEach(function(attr) { - node.attr('meta-' + attr.name, attr.value); + if(attr.value) + node.attr('meta-' + attr.name, attr.value); }); _.keys(this.data('other-attrs') || {}).forEach(function(key) { node.attr(key, this.data('other-attrs')[key]); -- 2.20.1