Add clear() to Element.classList.

We should support a fast way to remove all classes through the
classList instead of having to call removeAttribute() directly.

BUG=440529
R=ojan@chromium.org, rafaelw@chromium.org

Review URL: https://codereview.chromium.org/788093003
This commit is contained in:
Elliott Sprehn
2014-12-09 17:56:41 -08:00
parent 08b367be54
commit fc6b820dd7
2 changed files with 16 additions and 7 deletions

View File

@@ -1,12 +1,13 @@
Running 8 tests
Running 9 tests
ok 1 Class list should add multiple classes
ok 2 Class list should add classes in order
ok 3 Class list should remove classes
ok 4 Class list should remove multiple classes
ok 5 Class list should check for classes
ok 6 Class list should get classes by index
ok 7 Class list should toggle classes
ok 8 Class list should dynamically update style
8 tests
8 pass
ok 5 Class list should clear all classes
ok 6 Class list should check for classes
ok 7 Class list should get classes by index
ok 8 Class list should toggle classes
ok 9 Class list should dynamically update style
9 tests
9 pass
0 fail

View File

@@ -48,6 +48,14 @@ describe("Class list", function() {
assert.equal(target.classList.toString(), "second");
});
it("should clear all classes", function() {
target.classList.add("first");
target.classList.add("second");
target.classList.clear();
assert.equal(target.classList.toString(), "");
assert.isFalse(target.hasAttribute("class"));
});
it("should check for classes", function() {
target.classList.add("first", "second", "third");
assert.isTrue(target.classList.contains("first"));