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

Non-constructible constructors and Arrays

From: Alex Russell <slightlyoff@google.com>
Date: Wed, 27 Jul 2011 14:24:56 -0700
Message-ID: <CANr5HFU5PVs0ad_KDE+zVjKgrKFfpF_E0zFvVPx7BymJc9nedQ@mail.gmail.com>
To: public-script-coord@w3.org
Cc: Brendan Eich <brendan@mozilla.com>, Cameron McCormack <cam@mcc.id.au>
The topic of WebIDL's last call just came up at the TC39 face-to-face,
and one issue I've flagged but not posted here yet is the topic of
non-constructible constructors. Section 4.3.5 contains an explicit
example of a behavior that I'd like to see repaired:

    // from: http://www.w3.org/TR/2011/WD-WebIDL-20110712/#Constructor
    var z = new NodeList(); // This would throw a TypeError, since no
                                          // [Constructor] is declared.

Browsers expose many of these (HTMLDivElement, etc.) and from the
integration-with-ES perspective, they're mostly warts, not least of
all because they co-exist with *actually* constructible constructors
(Image, etc.).

I'd like to propose that instead of blessing the non-constructible
behavior that the lack of a [Constructor] *not* create a throwing
function, but instead create a regular factory in the style of Image.

On the topic of Arrays, I know it has come up before that there are
DOM collection types, in particular NodeList, which should be Array
subclass instances. I know that's outside the specifics of WebIDL, but
I'd like to make sure that there's at least some accommodation in
WebIDL for making this expressible until TC39 finishes the work of
making it possible to directly subclass Array. Perhaps my reading has
missed some infrastructure that might imply this or at least prevent
it from being possible in an extension today?

Regards
Received on Wednesday, 27 July 2011 21:25:51 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC