- From: Sylvain Pasche <sylvain.pasche@gmail.com>
- Date: Mon, 10 Aug 2009 19:48:57 +0200
On Mon, Aug 10, 2009 at 1:09 AM, Ian Hickson<ian at hixie.ch> wrote: > I've reworded it to imply only one mutation event fires. Thanks. > >> 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? > > I think that the spec now implies that you set the attribute to the empty > string. Do you agree? I don't think it changes the interpretation of this border case and I still think the spec implies that no attribute is added. Maybe the ambiguity is about the definition of mutation in the "when the object mutates this empty string" sentence. If we have an element with no class attribute and call .remove("foo"), we start the remove() algorithm with the empty string and it doesn't modify that string. So I would say that there wasn't a mutation and that no attribute should be added. One way to clarify that no attribute should be added might be (the change is between the parentheses): "When the attribute is absent, then the string represented by the object is the empty string; when the object mutates this empty string (that is, the algorithm changes the underlying string to a non-empty string), the user agent must add the corresponding content attribute, with its value set to the value it would have been set to after mutating the empty string." I also assume an "otherwise, do nothing" at the end of that sentence. Do you think somebody could interpret this as an "otherwise add an attribute set to the empty string"? Sylvain
Received on Monday, 10 August 2009 10:48:57 UTC