W3C home > Mailing lists > Public > public-html@w3.org > July 2008

Re: HTMLCollection item() vs. namedItem() with [] syntax (detailed review of the DOM)

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Thu, 10 Jul 2008 10:16:07 -0700
Message-ID: <c9e12660807101016w263d9cc3i10eaf27b7e4329df@mail.gmail.com>
To: public-html <public-html@w3.org>
On Thu, Jul 10, 2008 at 12:22 AM, Cameron McCormack <cam@mcc.id.au> wrote:
>
> Cameron McCormack:
>> > > That's different from what I currently have in the Bindings spec,
>> > > which is basically "do a ToUint32() on the property name, and if the
>> > > result is a non-negative integer, use the index getter, otherwise use
>> > > the name getter".
>
> Simon Pieters:
>> > Hmm, seems like ToUint32 converts things like NaN and Infinity to 0.

When used in property access, the Expression is converted to a string
value. NaN and +Infinity will be a "NaN" and "Infinity" respectively.

Try it:

(function() {
    var a = [];
    a.NaN = 12;
    a.Infinity = 13;
    a[0] = "z";
    alert(a[NaN]);
    alert(a[1/0]);

// no property named "0x0" - so undefined;
    alert(a["0x0"]);

// -0.0 => 0, resolve the "0" property on a.
    alert(a[-0.0]);
})()


>> > Browsers don't do that. So I don't think that's good enough... e.g., we
>> > want ["0x0"], [1/0], etc., to use the name getter.
>

A string value of the Expression will be used. If the Expression is
"0x0", then the property "0x0" (or undefined) will be returned.

[snip]

Garrett

> --
> Cameron McCormack ≝ http://mcc.id.au/
Received on Thursday, 10 July 2008 17:16:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:19 GMT