Re: [webidl] Defining constructors on non-global objects?

On 9/5/14, 2:40 AM, Kostiainen, Anssi wrote:
> What is the appropriate way to define constructors on non-global objects in WebIDL? IOW, here’s what we’d like to spec in WebIDL:
>
> new Sensor.AmbientLight();

There is no way to do this right now purely in IDL.

If this is the API you want, then for the moment you can define an 
AmbientLight factory method that returns an object of the right type, 
and the "new" call above will work due to how "new" works in JS.  But 
the returned object won't be instanceof Sensor.AmbientLight, and won't 
have Sensor.AmbientLight as its .constructor

There have been a few requests for this sort of thing now.  It's worth 
filing a bug on it if there isn't one already.

-Boris

Received on Friday, 5 September 2014 12:24:37 UTC