Re: DOM collections index out of bounds and JavaScript.

On Tue, 26 Oct 2010 23:06:08 +0200, 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.

I'm not sure I follow this. Could you elaborate a bit?


> 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?

Well, and you would need to define that base interface somewhere and all  
other specifications would need to use it. But I thought this was the  
point of sequence. I have been using it that way in the CSSOM at least to  
replace all these dreaded SomethingList interfaces/objects. Maybe we  
should introduce something else for it?


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Friday, 29 October 2010 13:18:22 UTC