From fc6b820dd7ebd5882e87a27606b5d37ec9a42662 Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Tue, 9 Dec 2014 17:56:41 -0800 Subject: [PATCH] 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 --- .../flutter/tests/lowlevel/classlist-expected.txt | 15 ++++++++------- engine/src/flutter/tests/lowlevel/classlist.sky | 8 ++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/engine/src/flutter/tests/lowlevel/classlist-expected.txt b/engine/src/flutter/tests/lowlevel/classlist-expected.txt index 523cc429d6..a924cfc8d8 100644 --- a/engine/src/flutter/tests/lowlevel/classlist-expected.txt +++ b/engine/src/flutter/tests/lowlevel/classlist-expected.txt @@ -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 diff --git a/engine/src/flutter/tests/lowlevel/classlist.sky b/engine/src/flutter/tests/lowlevel/classlist.sky index 1622fa4ac1..853a817823 100644 --- a/engine/src/flutter/tests/lowlevel/classlist.sky +++ b/engine/src/flutter/tests/lowlevel/classlist.sky @@ -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"));