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

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 UTC