Skip to content

Commit

Permalink
Merge pull request #82 from canjs/remove-class
Browse files Browse the repository at this point in the history
Element.removeAttribute updates className
  • Loading branch information
andrejewski committed Dec 27, 2017
2 parents 1f65b77 + ced7663 commit 39f533f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/simple-dom/document/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions lib/test/element-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 39f533f

Please sign in to comment.