Bug 111307

Summary: div.classList.add('a', 'a') creates duplicate entries
Product: WebKit Reporter: Michał Gołębiowski-Owczarek <m.goleb+bugzilla>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andrea.giammarchi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://jsfiddle.net/m_gol/xje3k/

Michał Gołębiowski-Owczarek
Reported 2013-03-04 05:56:32 PST
div.classList.add('a', 'a') should IMHO add only one instance of 'a' to div.classList.
Attachments
Michał Gołębiowski-Owczarek
Comment 1 2013-03-04 13:20:48 PST
One result of this issue is that results of invoking: div.classList.add(sth1, sth2); and: div.classList.add(sth1); div.classList.add(sth2); are different, which is unintuitive.
Michał Gołębiowski-Owczarek
Comment 2 2013-03-04 13:23:39 PST
(In reply to comment #1) > One result of this issue is that results of invoking: > > div.classList.add(sth1, sth2); > > and: > > div.classList.add(sth1); > div.classList.add(sth2); > > are different, which is unintuitive. Correction: results CAN be different, not ARE different, of course.
Michał Gołębiowski-Owczarek
Comment 3 2013-03-05 00:18:29 PST
OK, this is not only my view, this is what spec dictates: http://dom.spec.whatwg.org/#domtokenlist "A DOMTokenList object has an associated list of unique tokens, which is initially empty." So it's clearly WebKit's bug.
Michał Gołębiowski-Owczarek
Comment 4 2013-04-17 10:37:17 PDT
Andrea Giammarchi
Comment 5 2013-10-08 18:42:41 PDT
confirmed and fixed/verified through the test 74 in here: http://webreflection.github.io/dom4/test/ The check is basically this one: div.classList.add('a', 'b', 'a'); assert(div.className === 'a b'); the test against to verify it works is the one showed here: div.classList.add('a', 'a'); assert(div.className === 'a'); Very weird this bus hasn't been confirmed yet since it's clearly stated about being unique tokens. What would be the reason to have twice the same class otherwise, having an `!important` effect ? Thanks for fixing this, I don't really want to rely on JS to fix such simple CSS classList core gotcha. Best Regards
Michał Gołębiowski-Owczarek
Comment 6 2013-12-29 14:17:34 PST
The issue has been fixed in Chrome over two months ago, I also got some feedback in a sensible time after reporting. Meanwhile, here no one seems to bother. Could sb at least triage this? Important, not important, some milestone? This lack of response is disheartening.
Michał Gołębiowski-Owczarek
Comment 7 2015-08-28 11:20:17 PDT
I wish someone looked at those bug reports. :( Thankfully, this has been fixed in Safari 8.
Note You need to log in before you can comment on or make changes to this bug.