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

Re: Exposing constructors of readonly interfaces to web authors

From: Rik Cabanier <cabanier@gmail.com>
Date: Thu, 10 Jul 2014 18:42:01 +0200
Message-ID: <CAGN7qDDkKS6RMeV30AtQt+j1XuV+x7UARbUqBnx4XK399rdLaQ@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: Domenic Denicola <domenic@domenicdenicola.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
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

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