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

Re: DOM collections index out of bounds and JavaScript.

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Tue, 26 Oct 2010 15:51:12 -0700
Message-ID: <AANLkTi=K0HRcQbn88JUFR6qUwv5ziR_j8XaVDrcS3Rvj@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>, Garrett Smith <dhtmlkitchen@gmail.com>, Erik Arvidsson <arv@chromium.org>, public-webapps@w3.org
On 10/26/10, Cameron McCormack <cam@mcc.id.au> wrote:
> Anne van Kesteren:
>> Yeah, it would be nice if sequence mapped to that so that NodeList
>> could be defined as a sequence instead, same for StyleSheetList,
>> etc. And then Web IDL would take care of all the details rather than
>> each specification.
> I donít know that sequence is appropriate for this.  They are meant to
> be for pass-by-value lists.
> Is the issue here that you canít use a base interface because then you
> would lose some type specificity, e.g.
>   interface Collection {
>     attribute unsigned long length;
>     getter any item(unsigned long index);
>   }
> where you need to use ďanyĒ because you donít know what the type of the
> derived interface elements will be?

The "object" type would be more specific but that won't cover string
values as with CSSStyleDeclaration, e.g. `elem.style.item(3)`.

A sub-interface would override that `any` with the most specific
detail as it could, like "Node" for childNodes, "HTMLImageElement" for
document.images, et al.

Though with getter or forwarded [[Get]] proxy, implementations are
inconsistent. Some implementations have forwarded [[Get]], other times
it is just an object with a `k` property for each index less than
collection.length-1, and if the object does not have a property, the
result is `undefined`, which, as Erik mentions, is inconsistent with
the way any `item` method
is specified.
Received on Tuesday, 26 October 2010 22:51:49 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:13 UTC