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

On Mon, 09 Jul 2007 12:50:17 +0200, Cameron McCormack <cam@mcc.id.au>  
wrote:

>> Do these paragraphs mean the same thing? Why are they phrased  
>> differently?
>
> Yeah, they shouldn’t really be different since they are meant to say the
> same thing.  In any case, I expect those sections to replace/removed
> once the Language Bindings for DOM Specifications spec is published.
> Then, this behaviour can be specified from the IDL. [1]

Ok.

>> In any case, they don't quite match reality.
>>
>>    http://simon.html5.org/test/html/dom/htmlcollections/item-vs-namedItem/
>
> I did some similar tests too, though with some “tamer” values:
>
>   http://mcc.id.au/2007/05/binding-tests/
>
> (Specifically, test 036.)

Nice.

>> [...]
>>Below is what IE7 seems to do, where "obj" is what you pass to the  
>> [[Get]]
>> method...
>>
>>   1. If obj is an array, let obj be the array's first item.
>>
>>   2. If obj is an integer, a float or Infinity, then pass that to  
>> .item()
>>      and abort these steps.
>>
>>   3. If obj is a string, check whether the string matches the regex
>>      /^(\d+)(\..*)?$/. If it does, pass $1 to .item() and abort these
>> steps.
>>
>>   4. Pass obj.toString() to .namedItem().
>
> 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”.

Hmm, seems like ToUint32 converts things like NaN and Infinity to 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.

> Do you think IE7’s rules should be used?

I hope IE's behavior of splitting the string on some characters can be  
ignored, since the other browsers don't do it and it doesn't seem sane.  
However, cases like ["010"] can be debated.

> [1]  
> http://dev.w3.org/cvsweb/~checkout~/2006/webapi/Binding4DOM/Overview.html?rev=1.44&content-type=text/html;%20charset=utf-8#get
>

-- 
Simon Pieters
Opera Software

Received on Monday, 9 July 2007 13:29:44 UTC