Re: Feature-detectable API extensions?

On Aug 27, 2013, at 6:50 PM, Boris Zbarsky wrote:

> On 8/27/13 6:03 PM, Allen Wirfs-Brock wrote:
>> Based upon the above signature, IDBCursor.prototype.continue.length
>> should be 0.  I verified this on FF.
> 
> 0 is what's specced in WebIDL right now for this situation...
> 
>> void continue(any key, optional dictionary opts {string primaryKey);
>> 
>> according to the ES6 rules (assuming that the second argument is defined
>> as a ES6 default value parameter)
> 
> It's an odd case.  Dictionaries _are_ in fact something that always has a default value, but they're a somewhat special case that way; most things only have a default value when explicitly given one.
> 
> But further, WebIDL .length doesn't care about default values at all: it's based purely on whether arguments are optional or not.

I think that the appropriate translation of WebIDL to ES6 is that WebIDL "optional" always turns into an ES6 parameter with a default value initializer. If the WebIDL source includes an explicit default value then that value should be used as the ES6 default value.  If the WebIDL does not have an explicit default value then the implicit WebIDL default should be used as the ES6 default value.

If you do this, then the WebIDL length based upon "optional" should match the ES8 length based upon default value initializers.

Allen

Received on Wednesday, 28 August 2013 04:25:25 UTC