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

Re: Non-constructible constructors and Arrays

From: Brendan Eich <brendan@mozilla.com>
Date: Wed, 27 Jul 2011 22:58:07 -0700
Cc: Alex Russell <slightlyoff@google.com>, public-script-coord@w3.org, Cameron McCormack <cam@mcc.id.au>
Message-Id: <4923645A-ECEB-451A-8DEE-CEA830BF724F@mozilla.com>
To: Garrett Smith <dhtmlkitchen@gmail.com>
On Jul 27, 2011, at 10:32 PM, Garrett Smith wrote:

> On 7/27/11, Alex Russell <slightlyoff@google.com> wrote:
>> 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.
>> 
> Existing browser behavior seems fine by me.

Hi Garrett -- the issue isn't breaking existing behavior, it is extending it so you can "new" a NodeList. Is there a reason not to do this? Regularity in languages and APIs is better than irregular and seemingly arbitrary restrictions, all else equal.


>> 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.
> The problems with that were quickly uncovered on:
> "[whatwg] Adding ECMAScript 5 array extras to HTMLCollection"

You mean the thread containing your message:

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-August/027668.html

It's hard to tell what problems you mean, apart from browser differences that would be fixed by specifying better normative behavior, via WebIDL and relevant DOM and Web API specs. I mean, sure -- some browsers don't do the right thing with array generics on NodeList. This is not a reason to reject the idea of extending NodeList's spec (implementations to follow) so the generics work.

/be
Received on Thursday, 28 July 2011 05:58:37 UTC

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