does [Constructor] invocation require 'new' or not (generally)? · Issue #62 · whatwg/webidl · GitHub
Skip to content

does [Constructor] invocation require 'new' or not (generally)? #62

Closed
@travisleithead

Description

Related to issue #55, where in WebIDL does it say (or not say) that invoking constructable interfaces (those interfaces with [NamedConstructor] or one or more [Constructor] extended attributes) should throw when not used with new?

As far as I can tell, in section 4.5.1.1, this is all we get:

 The internal [[Call]] method of the interface object behaves as follows, assuming arg0..n−1 is the list of argument values passed to the constructor, and I is the interface:

1. If I was not declared with a [Constructor] extended attribute, then throw a TypeError.
2. Let id be the identifier of interface I.
3. Initialize S to the effective overload set for constructors with identifier id on interface I and with argument count n.
4. Let <constructor, values> be the result of passing S and arg0..n−1 to the overload resolution algorithm.
5. Let R be the result of performing the actions listed in the description of constructor with values as the argument values.
6. Return the result of converting R to an ECMAScript interface type value I.

Seems like what I'm looking for is wrapped up in step 5, but in my reading this step is deferring to prose for each individual constructor. Would this include requiring the use of new?

In Gecko and Blink, it looks constructable interfaces require new (at least for those I tested, e.g., Image(), XMLHttpRequest(), and in Gecko only ATM: DOMException()).

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions