diff --git a/lib/simple-dom/document/element.js b/lib/simple-dom/document/element.js index 66b37eb..08d76a1 100644 --- a/lib/simple-dom/document/element.js +++ b/lib/simple-dom/document/element.js @@ -92,6 +92,11 @@ Element.prototype.removeAttribute = function(name) { var attr = attributes[i]; if (attr.name === name) { attributes.splice(i, 1); + const special = attrSpecial[name]; + if(special) { + special(this, undefined); + } + delete attributes[name]; return; } diff --git a/lib/test/element-test.js b/lib/test/element-test.js index 30e3737..1a8641b 100644 --- a/lib/test/element-test.js +++ b/lib/test/element-test.js @@ -185,6 +185,15 @@ QUnit.test("setAttribute('class', value) updates the className", function(assert assert.equal(el.className, "foo bar", "Element's className is same as the attribute class"); }); +QUnit.test("removeAttribute('class') updates the className", function (assert) { + var document = new Document(); + var el = document.createElement("div"); + el.setAttribute("class", "foo bar"); + el.removeAttribute("class"); + + assert.equal(el.className, '', "Element's className is same as the attribute class"); +}); + QUnit.test("innerHTML does not parse the contents of SCRIPT and STYLE nodes", function (assert) { var document = new Document(); var div = document.createElement("div");