DOM collections index out of bounds and JavaScript.

When DOM was first spec'ed the collection interfaces all had some kind
of item method. These methods sometimes return like null[1] and
sometimes other values such as an empty string [2]. The JavaScript
bindings for these allows us to use indexed getters instead of calling
the item method.

The problem is that trying to get a non existing property in JS should
return undefined. Not null and not an empty string. I understand that
the spec used null since Java does not have undefined. Since we are
trying to realign these specs with the web it would make sense to try
to make them fit better with JavaScript and mandate that the JS
bindings for collections should return undefined for getting an item
out of bounds.

[1] http://dev.w3.org/html5/spec/Overview.html#dom-htmlcollection-item
[2] http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-item

erik

Received on Tuesday, 19 October 2010 00:52:33 UTC