diff --git a/index.bs b/index.bs index cf599fc5..9f41e4bc 100644 --- a/index.bs +++ b/index.bs @@ -1009,7 +1009,7 @@ The following extended attributes are applicable to interfaces: [{{Exposed}}], [{{Global}}], [{{LegacyWindowAlias}}], -[{{NamedConstructor}}], +[{{LegacyFactoryFunction}}], [{{NoInterfaceObject}}], [{{LegacyOverrideBuiltIns}}], and [{{SecureContext}}]. @@ -2211,7 +2211,7 @@ is the final argument in the operation’s argument list. [=Extended attributes=] that [=takes an argument list|take an argument list=] -([{{NamedConstructor}}], of those +([{{LegacyFactoryFunction}}], of those defined in this specification) and [=callback functions=] are also considered to be [=variadic=] when the ... token is used in their argument lists. @@ -3352,7 +3352,7 @@ definitions. Note that [=constructor operations=] and - [{{NamedConstructor}}] + [{{LegacyFactoryFunction}}] [=extended attributes=] are disallowed from appearing on [=partial interface=] definitions, so there is no need to also disallow overloading for constructors. @@ -3363,7 +3363,7 @@ An effective overload set represents the allowable invocations for a particular [=operation=], constructor (specified with a [=constructor operation=] -or [{{NamedConstructor}}]), or +or [{{LegacyFactoryFunction}}]), or [=callback function=]. The algorithm to [=compute the effective overload set=] operates on one of the following four types of IDL constructs, and listed with them below are @@ -3377,9 +3377,9 @@ the inputs to the algorithm needed to compute the set. : For constructors :: * the [=interface=] on which the [=constructor operations=] are to be found * the number of arguments to be passed - : For named constructors - :: * the [=interface=] on which the [{{NamedConstructor}}] [=extended attributes=] are to be found - * the [=identifier=] of the named constructors + : For legacy factory functions + :: * the [=interface=] on which the [{{LegacyFactoryFunction}}] [=extended attributes=] are to be found + * the [=identifier=] of the legacy factory function * the number of arguments to be passed An [=effective overload set=] is used, among other things, to determine whether there are @@ -3392,7 +3392,7 @@ whose [=tuple/items=] are described below: * A callable is an [=operation=] if the [=effective overload set=] is for [=regular operations=], [=static operations=], or [=constructor operations=]; and it is an [=extended attribute=] - if the [=effective overload set=] is for [=named constructors=]. + if the [=effective overload set=] is for [=legacy factory functions=]. * A type list is a [=list=] of IDL types. * An optionality list is a [=list=] of three possible optionality values @@ -3412,7 +3412,7 @@ the same operation or constructor. The algorithm below describes how to compute the effective overload set. The following input variables are used, if they are required: - * the identifier of the operation or named constructor is |A| + * the identifier of the operation or legacy factory function is |A| * the argument count is |N| * the interface is |I| @@ -3433,17 +3433,17 @@ the same operation or constructor. : For constructors :: The elements of |F| are the [=constructor operations=] on interface |I|. - : For named constructors + : For legacy factory functions :: The elements of |F| are the - [{{NamedConstructor}}] + [{{LegacyFactoryFunction}}] [=extended attributes=] on interface |I| whose [=takes a named argument list|named argument lists’=] identifiers are |A|. 1. Let |maxarg| be the maximum number of arguments the operations, - constructor extended attributes or callback functions in |F| are declared to take. - For [=variadic=] operations and constructor extended attributes, + legacy factory functions, or callback functions in |F| are declared to take. + For [=variadic=] operations and legacy factory functions, the argument on which the ellipsis appears counts as a single argument. Note: So void f(long x, long... y); is considered to be declared to take two arguments. @@ -6949,7 +6949,7 @@ which form (or forms) it is in: takes a named argument list - [NamedConstructor=Image(DOMString src)] + [LegacyFactoryFunction=Image(DOMString src)] @@ -7202,7 +7202,7 @@ and comprise the following: * [=interface objects=] * [=legacy callback interface objects=] -* [=named constructors=] +* [=legacy factory functions=] * [=interface prototype objects=] * [=named properties objects=] * [=iterator prototype objects=] @@ -9703,7 +9703,7 @@ The identifiers that Each of the [=LegacyWindowAlias identifier|identifiers=] of [{{LegacyWindowAlias}}] must not be the same as one used by a [{{LegacyWindowAlias}}] extended attribute on this interface or another interface, -must not be the same as the [=NamedConstructor identifier|identifier=] used by a [{{NamedConstructor}}] +must not be the same as the [=LegacyFactoryFunction identifier|identifier=] used by a [{{LegacyFactoryFunction}}] extended attribute on this interface or another interface, must not be the same as an [=identifier=] of an interface that has an [=interface object=], and must not be one of the [=reserved identifiers=]. @@ -9915,21 +9915,21 @@ is to be implemented. -

[NamedConstructor]

+

[LegacyFactoryFunction]

- [{{NamedConstructor}}] [=extended attribute=] is an undesirable feature. + [{{LegacyFactoryFunction}}] [=extended attribute=] is an undesirable feature. It exists only so that legacy Web platform features can be specified. It should not be used in specifications unless required to specify the behavior of legacy APIs, or for consistency with these APIs. Editors who wish to use this feature are strongly advised to discuss this - by filing an issue + by filing an issue before proceeding. - The [{{NamedConstructor}}] [=extended attribute=] appears on the following [=interfaces=]: + The [{{LegacyFactoryFunction}}] [=extended attribute=] appears on the following [=interfaces=]: {{HTMLAudioElement}}, {{HTMLOptionElement}}, and {{HTMLImageElement}}. [[HTML]] @@ -9937,30 +9937,26 @@ is to be implemented.
-If the [{{NamedConstructor}}] +If the [{{LegacyFactoryFunction}}] [=extended attribute=] appears on an [=interface=], it indicates that the ECMAScript global object will have a property with the -specified name whose value is a [=constructor=] that can +specified name whose value is a function that can create objects that implement the interface. -Multiple [{{NamedConstructor}}] extended +Multiple [{{LegacyFactoryFunction}}] extended attributes may appear on a given interface. -The [{{NamedConstructor}}] extended attribute must either -[=takes an identifier|take an identifier=] or +The [{{LegacyFactoryFunction}}] extended attribute must [=takes a named argument list|take a named argument list=]. The identifier that occurs directly after the -“=” is the [{{NamedConstructor}}]'s identifier. -The first form, [NamedConstructor=identifier], -has the same meaning as using an empty argument list, -[NamedConstructor=identifier()]. -For each [{{NamedConstructor}}] extended attribute on the interface, +“=” is the [{{LegacyFactoryFunction}}]'s identifier. +For each [{{LegacyFactoryFunction}}] extended attribute on the interface, there will be a way to construct an object that [=implements=] the interface by passing the specified arguments to the [=constructor=] that is the value of the aforementioned property. -The [=NamedConstructor identifier|identifier=] used for the named constructor must not -be the same as that used by a [{{NamedConstructor}}] +The [=LegacyFactoryFunction identifier|identifier=] used for the legacy factory function must not +be the same as that used by a [{{LegacyFactoryFunction}}] extended attribute on another interface, must not be the same as an [=LegacyWindowAlias identifier|identifier=] used by a [{{LegacyWindowAlias}}] extended attribute on this interface or another interface, @@ -9969,22 +9965,21 @@ that has an [=interface object=], and must not be one of the [=reserved identifiers=]. -The [{{NamedConstructor}}] and [{{Global}}] [=extended attributes=] must not be specified on the +The [{{LegacyFactoryFunction}}] and [{{Global}}] [=extended attributes=] must not be specified on the same [=interface=]. -See [[#named-constructors]] for details on how named constructors +See [[#legacy-factory-functions]] for details on how legacy factory functions are to be implemented.
The following IDL defines an interface that uses the - [{{NamedConstructor}}] extended + [{{LegacyFactoryFunction}}] extended attribute.
         [Exposed=Window,
-         NamedConstructor=Audio,
-         NamedConstructor=Audio(DOMString src)]
+         LegacyFactoryFunction=Audio(DOMString src)]
         interface HTMLAudioElement : HTMLMediaElement {
           // ...
         };
@@ -9992,18 +9987,21 @@ are to be implemented.
 
     An ECMAScript implementation that supports this interface will
     allow the construction of HTMLAudioElement
-    objects using the Audio [=constructor=].
+    objects using the Audio function.
 
     
         typeof Audio;                   // Evaluates to 'function'.
 
-        var a1 = new Audio();           // Creates a new object that implements
-                                        // HTMLAudioElement, using the zero-argument
-                                        // constructor.
-
         var a2 = new Audio('a.flac');   // Creates an HTMLAudioElement using the
                                         // one-argument constructor.
     
+ + As an additional legacy quirk, these factory functions will have a prototype + property equal to the prototype of the original interface: + +
+        console.assert(Audio.prototype === HTMLAudioElement.prototype);
+    
@@ -10109,7 +10107,7 @@ The [{{NoInterfaceObject}}] extended attribute must not be specified on an interface that has any [=constructors=] or [=static operations=] defined on it. -Note: Combining the [{{NoInterfaceObject}}] and [{{NamedConstructor}}] extended attribute is not +Note: Combining the [{{NoInterfaceObject}}] and [{{LegacyFactoryFunction}}] extended attribute is not forbidden, however. An interface that does not have the [{{NoInterfaceObject}}] extended @@ -11269,12 +11267,12 @@ there exists a corresponding property on the {{Window}} global object. The name of the property is the given [=LegacyWindowAlias identifier|identifier=], and its value is a reference to the [=interface object=] for the [=interface=]. -In addition, for every [{{NamedConstructor}}] extended attribute on an [=exposed=] interface, +In addition, for every [{{LegacyFactoryFunction}}] extended attribute on an [=exposed=] interface, a corresponding property exists on the ECMAScript global object. -The name of the property is the [{{NamedConstructor}}]'s [=NamedConstructor identifier|identifier=], -and its value is an object called a named constructor, -which allows construction of objects that implement the interface. -The characteristics of a named constructor are described in [[#named-constructors]]. +The name of the property is the [{{LegacyFactoryFunction}}]'s [=LegacyFactoryFunction identifier|identifier=], +and its value is an object called a legacy factory function, +which allows creation of objects that implement the interface. +The characteristics of a legacy factory function are described in [[#legacy-factory-functions]].

Interface object

@@ -11377,27 +11375,27 @@ default interfaces do not have such steps. -

Named constructors

+

Legacy factory functions

-A [=named constructor=] that exists due to one or more -[{{NamedConstructor}}] [=extended attributes=] -with a given [=NamedConstructor identifier|identifier=] is a [=built-in function object=]. +A [=legacy factory function=] that exists due to one or more +[{{LegacyFactoryFunction}}] [=extended attributes=] +with a given [=LegacyFactoryFunction identifier|identifier=] is a [=built-in function object=]. It allows constructing objects that implement the interface on which the -[{{NamedConstructor}}] extended attributes appear. +[{{LegacyFactoryFunction}}] extended attributes appear.
- The [=named constructor=] with [=NamedConstructor identifier|identifier=] |id| + The [=legacy factory function=] with [=LegacyFactoryFunction identifier|identifier=] |id| for a given [=interface=] |I| in Realm |realm| - is created as follows: + is created as follows: 1. Let |steps| be the following steps: 1. If {{NewTarget}} is undefined, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}. 1. Let |args| be the passed arguments. 1. Let |n| be the [=list/size=] of |args|. - 1. [=Compute the effective overload set=] for named constructors with [=identifier=] |id| + 1. [=Compute the effective overload set=] for legacy factory functions with [=identifier=] |id| on [=interface=] |I| and with argument count |n|, and let |S| be the result. 1. Let <|constructor|, |values|> be the result of passing |S| and |args| to the [=overload resolution algorithm=]. @@ -11413,7 +11411,7 @@ implement the interface on which the 1. Return |O|. 1. Let |F| be [=!=] CreateBuiltinFunction(|steps|, « », |realm|). 1. Perform [=!=] SetFunctionName(|F|, |id|). - 1. [=Compute the effective overload set=] for named constructors with [=identifier=] |id| + 1. [=Compute the effective overload set=] for legacy factory functions with [=identifier=] |id| on [=interface=] |I| and with argument count 0, and let |S| be the result. 1. Let |length| be the length of the shortest argument list of the entries in |S|. 1. Perform [=!=] SetFunctionLength(|F|, |length|). @@ -13255,13 +13253,14 @@ the Realm given as an argument. 1. [=list/iterate|For every=] [=LegacyWindowAlias identifier|identifier=] |id| in [{{LegacyWindowAlias}}]'s [=LegacyWindowAlias identifier|identifiers=]: 1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |interfaceObject|). - 1. If the |interface| is declared with a [{{NamedConstructor}}] [=extended attribute=], + 1. If the |interface| is declared with a [{{LegacyFactoryFunction}}] [=extended attribute=], then: - 1. [=list/iterate|For every=] [=NamedConstructor identifier|identifier=] |id| in - [{{NamedConstructor}}]'s [=NamedConstructor identifier|identifiers=]: - 1. Let |namedConstructor| be the result of [=create a named constructor|creating - a named constructor=] with |id| for |interface| in |realm|. - 1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |namedConstructor|). + 1. [=list/iterate|For every=] [=LegacyFactoryFunction identifier|identifier=] |id| in + [{{LegacyFactoryFunction}}]'s [=LegacyFactoryFunction identifier|identifiers=]: + 1. Let |legacyFactoryFunction| be the result of + [=create a legacy factory function|creating a legacy factory function=] with + |id| for |interface| in |realm|. + 1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |legacyFactoryFunction|). 1. [=list/iterate|For every=] [=callback interface=] |interface| that is [=exposed=] in |realm| and on which [=constants=] are defined: 1. Let |id| be |interface|'s [=identifier=]. @@ -14912,7 +14911,7 @@ terminal symbol const, an "A" is distinct from one named "a", and an [=extended attribute=] [namedconstructor] will not be recognized as -the [{{NamedConstructor}}] +the [{{LegacyFactoryFunction}}] extended attribute. Implicitly, any number of whitespace and