From: Aleksander Ɓukasz Date: Wed, 13 Aug 2014 08:06:56 +0000 (+0200) Subject: smartxml: removing node attributes by setting undefined as their value X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/f47eee9a0cadc2f342da542cff4b95ba737a8558?hp=4aeab46723e464d604ced64f9bddb8fa0921df5a smartxml: removing node attributes by setting undefined as their value Before this change calling Node.setAttr(undefined) was a noop. --- diff --git a/src/smartxml/core.js b/src/smartxml/core.js index b60bc2e..7326507 100644 --- a/src/smartxml/core.js +++ b/src/smartxml/core.js @@ -169,7 +169,11 @@ var elementNodeTransformations = { setAttr: function(name, value, silent) { var oldVal = this.getAttr(name); - this._$.attr(name, value); + if(_.isUndefined(value)) { + this._$.removeAttr(name); + } else { + this._$.attr(name, value); + } if(!silent) { this.triggerChangeEvent('nodeAttrChange', {attr: name, oldVal: oldVal, newVal: value}); }