W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

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

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Fri, 05 Sep 2014 08:24:05 -0400
Message-ID: <5409AB65.1000807@mit.edu>
To: public-script-coord@w3.org
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.

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC