W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Re: [DOMCore] Is Element.attributes live or static?

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 20 Jun 2011 00:06:14 -0700
Message-ID: <BANLkTi=C1bWuL=5i289qLQv8xDZ8J4J2aw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: www-dom@w3.org
On Sun, Jun 19, 2011 at 10:49 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>> I assume that web compatibility requires attributes to be live.
>
> It may well, yes....  In which case the current spec text is probably not
> ok.  Data would be good.

I think live is preferable for other reasons too. First off it's a
good idea for consistency with similar properties. Second, code like
the following would be very inefficient otherwise:

for (i = 0; i < el.attributes.length; i++) {
  if (el.attributes[i].name == "foo" ||
      el.attributes[i].name == "bar")
    doStuff(el.attributes[i].value);
  else
    doOtherStuff(el.attributes[i].value);
}

/ Jonas
Received on Monday, 20 June 2011 07:07:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:07 GMT