@@ -1010,7 +1010,7 @@ The following extended attributes are applicable to interfaces:
1010
1010
[{{Exposed}}],
1011
1011
[{{Global}}],
1012
1012
[{{LegacyWindowAlias}}],
1013
- [{{NamedConstructor }}],
1013
+ [{{LegacyFactoryFunction }}],
1014
1014
[{{NoInterfaceObject}}],
1015
1015
[{{LegacyOverrideBuiltIns}}], and
1016
1016
[{{SecureContext}}].
@@ -2212,7 +2212,7 @@ is the final argument in the operation’s argument list.
2212
2212
2213
2213
[=Extended attributes=]
2214
2214
that [=takes an argument list|take an argument list=]
2215
- ([{{NamedConstructor }}], of those
2215
+ ([{{LegacyFactoryFunction }}], of those
2216
2216
defined in this specification) and [=callback functions=]
2217
2217
are also considered to be [=variadic=]
2218
2218
when the <emu-t>...</emu-t> token is used in their argument lists.
@@ -3353,7 +3353,7 @@ definitions.
3353
3353
</pre>
3354
3354
3355
3355
Note that [=constructor operations=] and
3356
- [{{NamedConstructor }}]
3356
+ [{{LegacyFactoryFunction }}]
3357
3357
[=extended attributes=] are disallowed from appearing
3358
3358
on [=partial interface=] definitions,
3359
3359
so there is no need to also disallow overloading for constructors.
@@ -3364,7 +3364,7 @@ An <dfn id="dfn-effective-overload-set" export>effective overload set</dfn>
3364
3364
represents the allowable invocations for a particular
3365
3365
[=operation=],
3366
3366
constructor (specified with a [=constructor operation=]
3367
- or [{{NamedConstructor }}]), or
3367
+ or [{{LegacyFactoryFunction }}]), or
3368
3368
[=callback function=].
3369
3369
The algorithm to [=compute the effective overload set=]
3370
3370
operates on one of the following four types of IDL constructs, and listed with them below are
@@ -3378,9 +3378,9 @@ the inputs to the algorithm needed to compute the set.
3378
3378
: For constructors
3379
3379
:: * the [=interface=] on which the [=constructor operations=] are to be found
3380
3380
* the number of arguments to be passed
3381
- : For named constructors
3382
- :: * the [=interface=] on which the [{{NamedConstructor }}] [=extended attributes=] are to be found
3383
- * the [=identifier=] of the named constructors
3381
+ : For legacy factory functions
3382
+ :: * the [=interface=] on which the [{{LegacyFactoryFunction }}] [=extended attributes=] are to be found
3383
+ * the [=identifier=] of the legacy factory function
3384
3384
* the number of arguments to be passed
3385
3385
3386
3386
An [=effective overload set=] is used, among other things, to determine whether there are
@@ -3393,7 +3393,7 @@ whose [=tuple/items=] are described below:
3393
3393
* A <dfn for="effective overload set tuple">callable</dfn> is an [=operation=]
3394
3394
if the [=effective overload set=] is for [=regular operations=],
3395
3395
[=static operations=], or [=constructor operations=]; and it is an [=extended attribute=]
3396
- if the [=effective overload set=] is for [=named constructors =].
3396
+ if the [=effective overload set=] is for [=legacy factory functions =].
3397
3397
* A <dfn>type list</dfn> is a [=list=] of IDL types.
3398
3398
* An <dfn>optionality list</dfn> is a [=list=] of
3399
3399
three possible <dfn id="dfn-optionality-value" export>optionality values</dfn>
@@ -3413,7 +3413,7 @@ the same operation or constructor.
3413
3413
The algorithm below describes how to <dfn>compute the effective overload set</dfn>.
3414
3414
The following input variables are used, if they are required:
3415
3415
3416
- * the identifier of the operation or named constructor is |A|
3416
+ * the identifier of the operation or legacy factory function is |A|
3417
3417
* the argument count is |N|
3418
3418
* the interface is |I|
3419
3419
@@ -3434,17 +3434,17 @@ the same operation or constructor.
3434
3434
: For constructors
3435
3435
:: The elements of |F| are the
3436
3436
[=constructor operations=] on interface |I|.
3437
- : For named constructors
3437
+ : For legacy factory functions
3438
3438
:: The elements of |F| are the
3439
- [{{NamedConstructor }}]
3439
+ [{{LegacyFactoryFunction }}]
3440
3440
[=extended attributes=] on interface |I| whose
3441
3441
[=takes a named argument list|named argument lists’=]
3442
3442
identifiers are |A|.
3443
3443
</dl>
3444
3444
3445
3445
1. Let |maxarg| be the maximum number of arguments the operations,
3446
- constructor extended attributes or callback functions in |F| are declared to take.
3447
- For [=variadic=] operations and constructor extended attributes ,
3446
+ legacy factory functions, or callback functions in |F| are declared to take.
3447
+ For [=variadic=] operations and legacy factory functions ,
3448
3448
the argument on which the ellipsis appears counts as a single argument.
3449
3449
3450
3450
Note: So <code>void f(long x, long... y);</code> is considered to be declared to take two arguments.
@@ -6949,7 +6949,7 @@ which form (or forms) it is in:
6949
6949
<dfn id="dfn-xattr-named-argument-list" for="extended attribute" export>takes a named argument list</dfn>
6950
6950
</td>
6951
6951
<td>
6952
- <code>[NamedConstructor =Image(DOMString src)]</code>
6952
+ <code>[LegacyFactoryFunction =Image(DOMString src)]</code>
6953
6953
</td>
6954
6954
</tr>
6955
6955
<tr>
@@ -7202,7 +7202,7 @@ and comprise the following:
7202
7202
7203
7203
* [=interface objects=]
7204
7204
* [=legacy callback interface objects=]
7205
- * [=named constructors =]
7205
+ * [=legacy factory functions =]
7206
7206
* [=interface prototype objects=]
7207
7207
* [=named properties objects=]
7208
7208
* [=iterator prototype objects=]
@@ -9703,7 +9703,7 @@ The <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t>s that
9703
9703
Each of the [=LegacyWindowAlias identifier|identifiers=] of [{{LegacyWindowAlias}}]
9704
9704
must not be the same as one used by a [{{LegacyWindowAlias}}]
9705
9705
extended attribute on this interface or another interface,
9706
- must not be the same as the [=NamedConstructor identifier|identifier=] used by a [{{NamedConstructor }}]
9706
+ must not be the same as the [=LegacyFactoryFunction identifier|identifier=] used by a [{{LegacyFactoryFunction }}]
9707
9707
extended attribute on this interface or another interface,
9708
9708
must not be the same as an [=identifier=] of an interface that has an [=interface object=],
9709
9709
and must not be one of the [=reserved identifiers=].
@@ -9915,52 +9915,48 @@ is to be implemented.
9915
9915
</div>
9916
9916
9917
9917
9918
- <h4 id="NamedConstructor " extended-attribute lt="NamedConstructor ">[NamedConstructor ]</h4>
9918
+ <h4 id="LegacyFactoryFunction " extended-attribute lt="LegacyFactoryFunction ">[LegacyFactoryFunction ]</h4>
9919
9919
9920
9920
<div class="advisement">
9921
9921
9922
- [{{NamedConstructor }}] [=extended attribute=] is an undesirable feature.
9922
+ [{{LegacyFactoryFunction }}] [=extended attribute=] is an undesirable feature.
9923
9923
It exists only so that legacy Web platform features can be specified.
9924
9924
It should not be used in specifications
9925
9925
unless required to specify the behavior of legacy APIs,
9926
9926
or for consistency with these APIs.
9927
9927
Editors who wish to use this feature are strongly advised to discuss this
9928
- by <a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20[NamedConstructor ]">filing an issue</a>
9928
+ by <a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20[LegacyFactoryFunction ]">filing an issue</a>
9929
9929
before proceeding.
9930
9930
9931
9931
<small class="non-normative">
9932
- The [{{NamedConstructor }}] [=extended attribute=] appears on the following [=interfaces=]:
9932
+ The [{{LegacyFactoryFunction }}] [=extended attribute=] appears on the following [=interfaces=]:
9933
9933
{{HTMLAudioElement}},
9934
9934
{{HTMLOptionElement}}, and
9935
9935
{{HTMLImageElement}}. [[HTML]]
9936
9936
</small>
9937
9937
9938
9938
</div>
9939
9939
9940
- If the [{{NamedConstructor }}]
9940
+ If the [{{LegacyFactoryFunction }}]
9941
9941
[=extended attribute=]
9942
9942
appears on an [=interface=],
9943
9943
it indicates that the ECMAScript global object will have a property with the
9944
- specified name whose value is a [=constructor=] that can
9944
+ specified name whose value is a function that can
9945
9945
create objects that implement the interface.
9946
- Multiple [{{NamedConstructor }}] extended
9946
+ Multiple [{{LegacyFactoryFunction }}] extended
9947
9947
attributes may appear on a given interface.
9948
9948
9949
- The [{{NamedConstructor}}] extended attribute must either
9950
- [=takes an identifier|take an identifier=] or
9949
+ The [{{LegacyFactoryFunction}}] extended attribute must
9951
9950
[=takes a named argument list|take a named argument list=].
9952
9951
The <emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t> that occurs directly after the
9953
- “<emu-t>=</emu-t>” is the [{{NamedConstructor}}]'s <dfn lt="NamedConstructor identifier">identifier</dfn>.
9954
- The first form, <code>[NamedConstructor=<emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t>]</code>,
9955
- has the same meaning as using an empty argument list,
9956
- <code>[NamedConstructor=<emu-t class="regex"><a href="#prod-identifier">identifier</a></emu-t>()]</code>.
9957
- For each [{{NamedConstructor}}] extended attribute on the interface,
9952
+ “<emu-t>=</emu-t>” is the [{{LegacyFactoryFunction}}]'s <dfn lt="LegacyFactoryFunction identifier">identifier</dfn>.
9953
+ For each [{{LegacyFactoryFunction}}] extended attribute on the interface,
9958
9954
there will be a way to construct an object that
9959
9955
[=implements=] the interface by passing the specified arguments to the [=constructor=]
9960
9956
that is the value of the aforementioned property.
9961
9957
9962
- The [=NamedConstructor identifier|identifier=] used for the named constructor must not
9963
- be the same as that used by a [{{NamedConstructor }}]
9958
+ The [=LegacyFactoryFunction identifier|identifier=] used for the legacy factory function must not
9959
+ be the same as that used by a [{{LegacyFactoryFunction }}]
9964
9960
extended attribute on another interface, must not
9965
9961
be the same as an [=LegacyWindowAlias identifier|identifier=] used by a [{{LegacyWindowAlias}}]
9966
9962
extended attribute on this interface or another interface,
@@ -9969,41 +9965,43 @@ that has an [=interface object=],
9969
9965
and must not be one of the
9970
9966
[=reserved identifiers=].
9971
9967
9972
- The [{{NamedConstructor }}] and [{{Global}}] [=extended attributes=] must not be specified on the
9968
+ The [{{LegacyFactoryFunction }}] and [{{Global}}] [=extended attributes=] must not be specified on the
9973
9969
same [=interface=].
9974
9970
9975
- See [[#named-constructors ]] for details on how named constructors
9971
+ See [[#legacy-factory-functions ]] for details on how legacy factory functions
9976
9972
are to be implemented.
9977
9973
9978
9974
<div class="example">
9979
9975
9980
9976
The following IDL defines an interface that uses the
9981
- [{{NamedConstructor }}] extended
9977
+ [{{LegacyFactoryFunction }}] extended
9982
9978
attribute.
9983
9979
9984
9980
<pre highlight="webidl">
9985
9981
[Exposed=Window,
9986
- NamedConstructor=Audio,
9987
- NamedConstructor=Audio(DOMString src)]
9982
+ LegacyFactoryFunction=Audio(DOMString src)]
9988
9983
interface HTMLAudioElement : HTMLMediaElement {
9989
9984
// ...
9990
9985
};
9991
9986
</pre>
9992
9987
9993
9988
An ECMAScript implementation that supports this interface will
9994
9989
allow the construction of <code class="idl">HTMLAudioElement</code>
9995
- objects using the <code class="idl">Audio</code> [=constructor=] .
9990
+ objects using the <code class="idl">Audio</code> function .
9996
9991
9997
9992
<pre highlight="js">
9998
9993
typeof Audio; // Evaluates to 'function'.
9999
9994
10000
- var a1 = new Audio(); // Creates a new object that implements
10001
- // HTMLAudioElement, using the zero-argument
10002
- // constructor.
10003
-
10004
9995
var a2 = new Audio('a.flac'); // Creates an HTMLAudioElement using the
10005
9996
// one-argument constructor.
10006
9997
</pre>
9998
+
9999
+ As an additional legacy quirk, these factory functions will have a <code>prototype</code>
10000
+ property equal to the <code>prototype</code> of the original interface:
10001
+
10002
+ <pre highlight="js">
10003
+ console.assert(Audio.prototype === HTMLAudioElement.prototype);
10004
+ </pre>
10007
10005
</div>
10008
10006
10009
10007
@@ -10109,7 +10107,7 @@ The [{{NoInterfaceObject}}] extended attribute
10109
10107
must not be specified on an interface that has any
10110
10108
[=constructors=] or [=static operations=] defined on it.
10111
10109
10112
- Note: Combining the [{{NoInterfaceObject}}] and [{{NamedConstructor }}] extended attribute is not
10110
+ Note: Combining the [{{NoInterfaceObject}}] and [{{LegacyFactoryFunction }}] extended attribute is not
10113
10111
forbidden, however.
10114
10112
10115
10113
An interface that does not have the [{{NoInterfaceObject}}] extended
@@ -11269,12 +11267,12 @@ there exists a corresponding property on the {{Window}} global object.
11269
11267
The name of the property is the given [=LegacyWindowAlias identifier|identifier=],
11270
11268
and its value is a reference to the [=interface object=] for the [=interface=].
11271
11269
11272
- In addition, for every [{{NamedConstructor }}] extended attribute on an [=exposed=] interface,
11270
+ In addition, for every [{{LegacyFactoryFunction }}] extended attribute on an [=exposed=] interface,
11273
11271
a corresponding property exists on the ECMAScript global object.
11274
- The name of the property is the [{{NamedConstructor }}]'s [=NamedConstructor identifier|identifier=],
11275
- and its value is an object called a <dfn id="dfn-named-constructor " export>named constructor</dfn>,
11276
- which allows construction of objects that implement the interface.
11277
- The characteristics of a named constructor are described in [[#named-constructors ]].
11272
+ The name of the property is the [{{LegacyFactoryFunction }}]'s [=LegacyFactoryFunction identifier|identifier=],
11273
+ and its value is an object called a <dfn id="dfn-legacy-factory-function " export oldids="dfn-named- constructor">legacy factory function </dfn>,
11274
+ which allows creation of objects that implement the interface.
11275
+ The characteristics of a legacy factory function are described in [[#legacy-factory-functions ]].
11278
11276
11279
11277
11280
11278
<h4 id="interface-object" oldids="es-interface-call,es-constructible-interfaces">Interface object</h4>
@@ -11377,27 +11375,27 @@ default interfaces do not have such steps.
11377
11375
</div>
11378
11376
11379
11377
11380
- <h4 id="named-constructors">Named constructors </h4>
11378
+ <h4 id="legacy-factory-functions" oldids=" named-constructors">Legacy factory functions </h4>
11381
11379
11382
- A [=named constructor =] that exists due to one or more
11383
- [{{NamedConstructor }}] [=extended attributes=]
11384
- with a given [=NamedConstructor identifier|identifier=] is a [=built-in function object=].
11380
+ A [=legacy factory function =] that exists due to one or more
11381
+ [{{LegacyFactoryFunction }}] [=extended attributes=]
11382
+ with a given [=LegacyFactoryFunction identifier|identifier=] is a [=built-in function object=].
11385
11383
It allows constructing objects that
11386
11384
implement the interface on which the
11387
- [{{NamedConstructor }}] extended attributes appear.
11385
+ [{{LegacyFactoryFunction }}] extended attributes appear.
11388
11386
11389
11387
<div algorithm>
11390
11388
11391
- The [=named constructor =] with [=NamedConstructor identifier|identifier=] |id|
11389
+ The [=legacy factory function =] with [=LegacyFactoryFunction identifier|identifier=] |id|
11392
11390
for a given [=interface=] |I| in Realm |realm|
11393
- is <dfn lt="create a named constructor ">created</dfn> as follows:
11391
+ is <dfn lt="create a legacy factory function ">created</dfn> as follows:
11394
11392
11395
11393
1. Let |steps| be the following steps:
11396
11394
1. If {{NewTarget}} is <emu-val>undefined</emu-val>, then
11397
11395
[=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
11398
11396
1. Let |args| be the passed arguments.
11399
11397
1. Let |n| be the [=list/size=] of |args|.
11400
- 1. [=Compute the effective overload set=] for named constructors with [=identifier=] |id|
11398
+ 1. [=Compute the effective overload set=] for legacy factory functions with [=identifier=] |id|
11401
11399
on [=interface=] |I| and with argument count |n|, and let |S| be the result.
11402
11400
1. Let <|constructor|, |values|> be the result of passing |S| and
11403
11401
|args| to the [=overload resolution algorithm=].
@@ -11413,7 +11411,7 @@ implement the interface on which the
11413
11411
1. Return |O|.
11414
11412
1. Let |F| be [=!=] <a abstract-op>CreateBuiltinFunction</a>(|steps|, « », |realm|).
11415
11413
1. Perform [=!=] <a abstract-op>SetFunctionName</a>(|F|, |id|).
11416
- 1. [=Compute the effective overload set=] for named constructors with [=identifier=] |id|
11414
+ 1. [=Compute the effective overload set=] for legacy factory functions with [=identifier=] |id|
11417
11415
on [=interface=] |I| and with argument count 0, and let |S| be the result.
11418
11416
1. Let |length| be the length of the shortest argument list of the entries in |S|.
11419
11417
1. Perform [=!=] <a abstract-op>SetFunctionLength</a>(|F|, |length|).
@@ -13251,13 +13249,14 @@ the Realm given as an argument.
13251
13249
1. [=list/iterate|For every=] [=LegacyWindowAlias identifier|identifier=] |id| in
13252
13250
[{{LegacyWindowAlias}}]'s [=LegacyWindowAlias identifier|identifiers=]:
13253
13251
1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |interfaceObject|).
13254
- 1. If the |interface| is declared with a [{{NamedConstructor }}] [=extended attribute=],
13252
+ 1. If the |interface| is declared with a [{{LegacyFactoryFunction }}] [=extended attribute=],
13255
13253
then:
13256
- 1. [=list/iterate|For every=] [=NamedConstructor identifier|identifier=] |id| in
13257
- [{{NamedConstructor}}]'s [=NamedConstructor identifier|identifiers=]:
13258
- 1. Let |namedConstructor| be the result of [=create a named constructor|creating
13259
- a named constructor=] with |id| for |interface| in |realm|.
13260
- 1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |namedConstructor|).
13254
+ 1. [=list/iterate|For every=] [=LegacyFactoryFunction identifier|identifier=] |id| in
13255
+ [{{LegacyFactoryFunction}}]'s [=LegacyFactoryFunction identifier|identifiers=]:
13256
+ 1. Let |legacyFactoryFunction| be the result of
13257
+ [=create a legacy factory function|creating a legacy factory function=] with
13258
+ |id| for |interface| in |realm|.
13259
+ 1. Perform [=!=] [$CreateMethodProperty$](|target|, |id|, |legacyFactoryFunction|).
13261
13260
1. [=list/iterate|For every=] [=callback interface=] |interface| that is [=exposed=] in
13262
13261
|realm| and on which [=constants=] are defined:
13263
13262
1. Let |id| be |interface|'s [=identifier=].
@@ -14908,7 +14907,7 @@ terminal symbol <emu-t>const</emu-t>, an
14908
14907
"<code>A</code>" is distinct from one named "<code>a</code>", and an
14909
14908
[=extended attribute=]
14910
14909
[<code class="idl">namedconstructor</code>] will not be recognized as
14911
- the [{{NamedConstructor }}]
14910
+ the [{{LegacyFactoryFunction }}]
14912
14911
extended attribute.
14913
14912
14914
14913
Implicitly, any number of <emu-t class="regex"><a href="#prod-whitespace">whitespace</a></emu-t> and
0 commit comments