Re: Value returned for missing DOMStringList properties

Sylvain Pasche <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
On 8/3/2009 5:55 PM, Martin Honnen wrote:
> The ECMAScript binding
> (http://www.w3.org/TR/DOM-Level-3-Core/ecma-script-binding.html) clearly
> says:
>
> "Objects that implement the DOMStringList interface:
>
> Properties of objects that implement the DOMStringList interface:
>
> length
> This read-only property is a Number.
>
> Functions of objects that implement the DOMStringList interface:
>
> item(index)
> This function returns a String.
> The index parameter is a Number.
> Note: This object can also be dereferenced using square bracket notation
> (e.g. obj[1]). Dereferencing with an integer index is equivalent to
> invoking the item function with that index."
>
> so with JavaScript whether you use someDOMStringList.item(100) or
> someDOMStringList[100] should not matter, the result should be the same.

Thanks, I forgot to look at that part. That leaves no ambiguity.

Apparently, other interfaces such as NodeList or NamedNodeMap have the 
same behavior. So I would expect something like:

document.body.childNodes.item(100);
	-> null
document.body.childNodes[100];
	-> null
document.body.attributes.item(100);
	-> null
document.body.attributes[100];
	-> null

However, Gecko/WebKit/Opera return:

null
undefined
null
undefined

IE does:

(throws an exception)
undefined
null
null

So I'm not sure where to go from there regarding DOMStringList: make it 
conformant but non consistent with other DOM interfaces, or 
non-conformant but consistent? Is there an ongoing effort to standardize 
what browsers are currently doing?


Sylvain
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.