This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
http://dom.spec.whatwg.org/#interface-domtokenlist It'd be nice if we could change this: if (foo != e.classList.has('foo')) e.classList.toggle('foo'); ...to: e.classList.set('foo', foo); ...or some such.
Oh, I see, toggle() does this if given a second argument.
FWIW, I didn't know it did that, and I've always overridden .set to have that behavior. I think it makes more intuitive sense on .set than on .toggle, eg. classList.set("foo", true). But it seems to be implemented already on .toggle in Chrome (not Firefox), and I guess it's not enough of a difference to change it now.
> (not Firefox) Uh... Firefox 24 and later implement it.