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

Re: DOM collections index out of bounds and JavaScript.

From: Cameron McCormack <cam@mcc.id.au>
Date: Tue, 19 Oct 2010 14:11:25 +1300
To: Erik Arvidsson <arv@chromium.org>
Cc: public-webapps@w3.org, Anne van Kesteren <annevk@opera.com>
Message-ID: <20101019011125.GL27738@wok.mcc.id.au>
Erik Arvidsson:
> 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.

Does it particularly matter that collection.item(999) returns null while
collection['999'] evaluates to undefined?  To me, it makes sense enough.
Functions and properties that returns Nodes, and which have no Node to
return, return null.  I think for consistency with all of these other
funtions and properties, it is preferable to return null from
collection.item().  That’s a much bigger (better) consistency to strive
for than one between collection.item(999) and collection['999'], IMO.

-- 
Cameron McCormack ≝ http://mcc.id.au/
Received on Tuesday, 19 October 2010 01:12:02 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:41 GMT