Re: Exposing constructors of readonly interfaces to web authors

On Thu, Jul 10, 2014 at 6:09 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 7/10/14, 10:55 AM, Rik Cabanier wrote:
>
>> What if instead of interfaces, we just define them as dictionaries:
>>
>
> The JS reflection of a dictionary (what you get after converting a Web IDL
> dictionary to a JS value) is an object with some value properties.
>
>
>           Object.defineProperty(this.bounds, 'left', { enumerable:
>>     true,get: function() {
>>     return Math.min(Math.min(self.p1.x, self.p2.x), Math.min(self.p3.x,
>>     self.p4.x));
>>          } });
>>
>
> So that's not a dictionary.
>

hmm, ok so it seems this can't be done without magical behavior so we need
DOMRect/DOMRectReadOnly to be instances.


> Furthermore, why is it a good idea to have these getters on a per-instance
> basis instead of on a shared prototype?


It was to avoid introducing another instance. Is there a way in IDL to have
a constructor but not have the class available in the global object?

Received on Thursday, 10 July 2014 16:42:29 UTC