W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2010

Re: [DOMCore] Attr

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 10 Sep 2010 09:41:01 -0700
Message-ID: <AANLkTimmT0JM9TpYG6xJXBy5575rpnh1Rqgtn2L=fN09@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Anne van Kesteren <annevk@opera.com>, Ojan Vafai <ojan@chromium.org>, Maciej Stachowiak <mjs@apple.com>, Boris Zbarsky <bzbarsky@mit.edu>, "Olli@pettay.fi" <Olli@pettay.fi>, Adrian Bateman <adrianba@microsoft.com>, WebApps WG <public-webapps@w3.org>
On Fri, Sep 10, 2010 at 9:28 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Fri, Sep 10, 2010 at 7:48 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> On Fri, Sep 10, 2010 at 5:35 AM, Anne van Kesteren <annevk@opera.com> wrote:
>>> 3) We can drop the concept of Attr being an object altogether. I do not
>>> think this is doable compatibility-wise, but not having Node.attributes,
>>> Attr, and just using getAttribute/getAttributeNS/setAttribute/setAttributeNS
>>> would be very nice complexity-wise.
>>
>> I know that I've written code that depends on Node.attributes, when I
>> was just looping through all of the attributes for some reason
>> (usually because I was transforming the element into something else,
>> and just wanted to transfer all the irrelevant attributes over).
>>
>> This code would happen to break with approach #2 as well, but the
>> relevant code I've written was minor and shouldn't be used by anyone
>> else, I think.
>
> Indeed, Node.attributes is currently the only way to enumerate all the
> attributes of an Element. This makes me think there are probably
> people out there doing this, and so I suspect Node.attributes is
> needed for web compat. Additionally, it seems bad to remove the
> ability to enumerate attributes completely. Lastly, keeping Attrs as a
> type of object gives us something to return from DOM-XPath.
>
> What I suggest is #2 in Anne's list. Make Attrs into objects with the
> following properties:
>
> * name
> * value
> * namespaceURI
> * localName
>
> 'name' would be my guess for most commonly used when iterating all the
> atttributes. The others are the minimum set of attributes needed for
> proper enumeration
>
> We might also consider these attributes, though if they're not needed
> for web compat, then it would be nice to not add them IMHO.
>
> * ownerElement
> * prefix
> * nodeName
> * nodeValue

Oh right, duh.  Sorry, wasn't reading #2 properly.  Yeah, with an
appropriate subset of values, #2 would be great for all the code I've
ever written.


> Also, I wouldn't mind making value/nodeValue readonly, but I don't
> feel strongly about that.

I've never written to a value obtained from Node.attributes.

~TJ
Received on Friday, 10 September 2010 16:41:54 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:40 GMT