W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2010

DOM collections index out of bounds and JavaScript.

From: Erik Arvidsson <arv@chromium.org>
Date: Mon, 18 Oct 2010 17:51:43 -0700
Message-ID: <AANLkTik26ycL9hSAj88XnCwP6yf4vKn9BroB88W5qhY3@mail.gmail.com>
To: public-webapps@w3.org
Cc: Anne van Kesteren <annevk@opera.com>
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

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

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:28 UTC