[Bug 17708] DOMTokenList: Ability to swap a class

https://www.w3.org/Bugs/Public/show_bug.cgi?id=17708

--- Comment #9 from Marcos Caceres <w3c@marcosc.com> 2012-07-08 23:47:12 UTC ---
(In reply to comment #7)
> The video might demonstrate that manipulating classList instead of className is
> more efficient (would have to see the code running in several browsers to be
> sure). 

Agree. Need more testing here. 

>However once you have classList you can do swap using add() and
> remove(). That is probably about as efficient as a replace() method would be.
> And I agree with Glenn that replace() is kind of a weird semantic for classes.
> (Although I will concede that many people seem to use a replace pattern.)

The problem with add and remove is that it changes the ordering of the classes.
This does not matter on the CSS cascade side, but it matters on the javascript
side because devs tend to string literal checks:

if(foo.className == "a b"){ ... }

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Sunday, 8 July 2012 23:47:13 UTC