- From: Aryeh Gregor <notifications@github.com>
- Date: Tue, 18 Apr 2017 11:21:39 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/443@github.com>
Accidentally filed as w3c/dom#118.
> Per the current spec, this outputs "a b c c d d":
>
> ```html
> data:text/html,<!doctype html>
> <script>
> var res = "";
> var span = document.createElement("span");
> span.setAttribute("class", "a a");
> span.classList.add("a");
> res += span.getAttribute("class");
> span.setAttribute("class", "b b");
> span.classList.remove("a");
> res += " " + span.getAttribute("class");
> span.setAttribute("class", "c c");
> span.classList.toggle("c", true);
> res += " " + span.getAttribute("class");
> span.setAttribute("class", "d d");
> span.classList.toggle("a", false);
> res += " " + span.getAttribute("class");
> document.documentElement.textContent = res;
> </script>
> ```
>
> This is not consistent. If we want add/remove to normalize even if they're no-ops, so should toggle. This is especially true because force-toggle is otherwise precisely identical AFAICT, and the slight difference is confusing.
>
> replace also doesn't normalize if the token doesn't exist, but that doesn't bother me as much since it doesn't otherwise behave identically to add/remove.
> I hit this because it complicates testing -- if force-toggle worked the same as add/remove, we could reuse add/remove tests for force-toggle for free.
I do have tests, which I'm [submitting upstream](https://bugzilla.mozilla.org/show_bug.cgi?id=1354066).
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/443
Received on Tuesday, 18 April 2017 18:22:19 UTC