- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Tue, 26 Oct 2010 15:51:12 -0700
- 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