Re: Array-with-item in WebIDL

On Jun 9, 2015, at 9:45 PM, Jonas Sicking wrote:

> ...
> 
> The only thing preventing us from doing this is that the DOM classes
> for historical reasons have a .item() function on them. This .item()
> function is redundant and most developers simply use domObject[n]
> rather than domObject.item(n). Sadly the .item() functions seem used
> enough that switching to Arrays isn't web compatible.
> 
> I was thinking we could introduce a sequence_with_item<...> type in
> WebIDL. This would simply map to a real Array object, but one which
> has a .item function added to it. Either by adding a .item function on
> the returned object itself, or by making the return object have a
> different prototype, but otherwise be a normal Array.
> 
> Obviously an alternative is to just leave things as status-quo.
> 
> / Jonas
> 

It would seem straight forward to definesequence_with_item<...> as essentially an ES6 subclass of Array that adds an `item` method.  It would inherit all of the Array methods and semantics

Allen

Received on Thursday, 11 June 2015 00:19:58 UTC