Re: Value returned for missing DOMStringList properties
Martin Honnen <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
Sylvain Pasche wrote:
> DOMStringList is currently returning null when calling item() with
> properties that don't exist, and the empty string when getting a missing
> indexed property. Here's an example with a document that has less than
> 100 style sheet sets:
>
> document.styleSheetSets.item(100)
> -> null
> document.styleSheetSets[100]
> -> ""
>
> Apparently, the behavior when getting missing indexed properties isn't
> specified in the DOM Level 3 Core specification yet [1].
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.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/