From: Aleksander Ɓukasz Date: Wed, 10 Jul 2013 11:00:28 +0000 (+0200) Subject: Remvoing wlxml class information from DocumentNodeElement X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/00d1285a2038e326246c5f5ff3bca7728f67925b?ds=sidebyside;hp=d67ed5177c7b434beb026aab16a91333e295a914 Remvoing wlxml class information from DocumentNodeElement --- diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index e122a1a..3b251f6 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -103,6 +103,8 @@ describe('Canvas', function() { expect(section.getWlxmlClass()).to.equal('some.class'); section.setWlxmlClass('some.other.class'); expect(section.getWlxmlClass()).to.equal('some.other.class'); + section.setWlxmlClass(null); + expect(section.getWlxmlClass()).to.be.undefined; }); }); }); diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index e18f856..88287b8 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -112,10 +112,16 @@ $.extend(DocumentNodeElement.prototype, { this.$element.attr('wlxml-tag', tag); }, getWlxmlClass: function() { - return this.$element.attr('wlxml-class').replace('-', '.'); + var klass = this.$element.attr('wlxml-class'); + if(klass) + return klass.replace('-', '.'); + return undefined; }, setWlxmlClass: function(klass) { - this.$element.attr('wlxml-class', klass); + if(klass) + this.$element.attr('wlxml-class', klass); + else + this.$element.removeAttr('wlxml-class'); }, is: function(what) { if(what === 'list' && _.contains(['list-items', 'list-items-enum'], this.$element.attr('wlxml-class')))