[whatwg] DOMTokenList: mutation clarification

Sylvain Pasche sylvain.pasche at gmail.com
Thu Jul 9 10:10:49 PDT 2009


1) in 

"When the attribute is absent, then the string represented by the object 
is the empty string; when the object mutates this empty string, the user 
agent must first add the corresponding content attribute, and then 
mutate that attribute instead"

Does it mean it should fire two DOMAttrModified events, one with the 
empty string addition, and the other with the attribute mutation?

I think it should simply fire only one mutation event in that case as in 
all other cases (should be simpler and more efficient, although that 
case shouldn't happen very often). I don't see a good reason to fire one 
with the empty string.

2) (using the class attribute for the discussion) What should happen 
when you do a remove("foo") on an element which has no class attribute?

My understanding is that it shouldn't add a class attribute with an 
empty string. That's because the remove() algorithm starts with an empty 
string and doesn't change it, so the " when the object mutates this 
empty string, " case shouldn't be true (and thus no attribute 
modification should happen).

However Simon's testcase [1] doesn't agree with this, and adds an empty 
string. So maybe it's worth clarifying this situation?



More information about the whatwg mailing list