W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2013

Re: [whatwg] [dom] attributes collection not fully defined?

From: Michael Day <mikeday@yeslogic.com>
Date: Thu, 30 May 2013 14:06:21 +1000
Message-ID: <51A6D03D.9090904@yeslogic.com>
To: whatwg@lists.whatwg.org
Hi Boris,

Thank you for the detailed explanation. Having the WebIDL named getter 
definition helps to simplify things.

This part still seems inconsistent with current browsers:

> 4)  Setting a property name that is currently exposed does a Reject
>      (which means throw in strict mode, silently do nothing in
>      non-strict mode).  Unless there is a named setter, of course.

If I set the property name which has already been used for an attribute, 
it still seems to store the value:

     div.setAttribute("fruit", "orange");
     div.attributes.fruit = "apple";
     div.removeAttribute("fruit");
     alert(div.attributes.fruit); // apple

except for a very strange bug in Firefox only, where if I *read* the 
value before removing it, the attribute doesn't go away later:

     div.setAttribute("fruit", "orange");
     div.attributes.fruit = "apple";
     alert(div.attributes.fruit.value); // orange
     div.removeAttribute("fruit");
     alert(div.attributes.fruit); // [object Attr] ???

Just adding the extra alert in the middle changes the value after 
removing the attribute, so that the Attr object is still returned.

Anyway, doing nothing or throwing if the user tries to write to a 
property which is currently exposed seems like a much better option.

Best regards,

Michael

-- 
Prince: Print with CSS!
http://www.princexml.com
Received on Thursday, 30 May 2013 04:06:52 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:59 UTC