@@ -1336,7 +1336,8 @@ be retrieved and (in some cases) changed. There are two kinds of attributes:
13361336
13371337If an attribute has no <emu-t>static</emu-t> keyword, then it declares a
13381338<dfn id="dfn-regular-attribute" export>regular attribute</dfn>. Otherwise,
1339- it declares a [=static attribute=].
1339+ it declares a [=static attribute=]. Note that in addition to being [=interface members=],
1340+ [=read only=] [=regular attributes=] can be [=namespace members=] as well.
13401341
13411342The [=identifier=] of an
13421343[=attribute=]
@@ -3942,8 +3943,11 @@ associated behaviors.
39423943 };
39433944</pre>
39443945
3945- A namespace is a specification of a set of <dfn id="dfn-namespace-member" export lt="namespace member">namespace members</dfn> (matching <emu-nt><a href="#prod-NamespaceMembers">NamespaceMembers</a></emu-nt>), which are the [=regular operations=] that appear between the braces in
3946- the namespace declaration. These operations describe the behaviors packaged into the
3946+ A namespace is a specification of a set of
3947+ <dfn id="dfn-namespace-member" export lt="namespace member">namespace members</dfn>
3948+ (matching <emu-nt><a href="#prod-NamespaceMembers">NamespaceMembers</a></emu-nt>), which are the
3949+ [=regular operations=] and [=read only=] [=regular attributes=] that appear between the braces in
3950+ the namespace declaration. These operations and attributes describe the behaviors packaged into the
39473951namespace.
39483952
39493953As with interfaces, the IDL for namespaces can be split into multiple parts by using
@@ -3992,28 +3996,32 @@ namespaces.
39923996<pre class="grammar" id="prod-NamespaceMember">
39933997 NamespaceMember :
39943998 ReturnType OperationRest
3999+ "readonly" AttributeRest
39954000</pre>
39964001
3997- <div class="example">
4002+ <div class="example" id="example-namespace" >
39984003
39994004 The following [=IDL fragment=] defines an
40004005 [=namespace=].
40014006
40024007 <pre highlight="webidl">
40034008 namespace VectorUtils {
4009+ readonly attribute Vector unit;
40044010 double dotProduct(Vector x, Vector y);
40054011 Vector crossProduct(Vector x, Vector y);
40064012 };
40074013 </pre>
40084014
40094015 An ECMAScript implementation would then expose a global property named
40104016 <code>VectorUtils</code> which was a simple object (with prototype
4011- [=%ObjectPrototype%=]) with enumerable data properties for each declared operation:
4017+ [=%ObjectPrototype%=]) with enumerable data properties for each declared operation, and
4018+ enumerable get-only accessors for each declared attribute:
40124019
40134020 <pre highlight="js">
40144021 Object.getPrototypeOf(VectorUtils); // Evaluates to Object.prototype.
40154022 Object.keys(VectorUtils); // Evaluates to ["dotProduct", "crossProduct"].
40164023 Object.getOwnPropertyDescriptor(VectorUtils, "dotProduct"); // Evaluates to { value: <a function>, enumerable: true, configurable: true, writable: true }.
4024+ Object.getOwnPropertyDescriptor(VectorUtils, "unit"); // Evaluates to { get: <a function>, enumerable: true, configurable: true }.
40174025 </pre>
40184026</div>
40194027
@@ -8607,6 +8615,9 @@ extended attribute must not also be declared
86078615with the [{{PutForwards}}]
86088616or [{{Replaceable}}] extended attributes.
86098617
8618+ The [{{LenientSetter}}] extended attribute must not be used on an attribute declared on a
8619+ [=namespace=].
8620+
86108621See the <a href="#es-attributes">Attributes</a> section for how
86118622[{{LenientSetter}}] is to be implemented.
86128623
@@ -8657,6 +8668,9 @@ must
86578668It must not be used on a
86588669[=static attribute=].
86598670
8671+ The [{{LenientThis}}] extended attribute must not be used on an attribute declared on a
8672+ [=namespace=].
8673+
86608674<p class="advisement">
86618675 Specifications should not use [{{LenientThis}}]
86628676 unless required for compatibility reasons. Specification authors who
@@ -9050,7 +9064,7 @@ must not be used on a
90509064
90519065The [{{PutForwards}}] extended attribute
90529066must not be used on an attribute declared on
9053- a [=callback interface=].
9067+ a [=callback interface=] or [=namespace=] .
90549068
90559069See the <a href="#es-attributes">Attributes</a> section for how
90569070[{{PutForwards}}]
@@ -9500,6 +9514,9 @@ appear on an [=operation=], then
95009514it must appear on all operations with
95019515the same [=identifier=] on that interface.
95029516
9517+ The [{{Unforgeable}}] extended attribute must not be used on an attribute declared on a
9518+ [=namespace=].
9519+
95039520If an attribute or operation |X| is [=unforgeable=]
95049521on an interface |A|, and |A| is one of the
95059522[=inherited interfaces=]
@@ -9600,6 +9617,9 @@ extended attribute must not appear on
96009617anything other than a [=regular attribute=]
96019618or [=regular operation=].
96029619
9620+ The [{{Unscopable}}] extended attribute must not be used on an attribute declared on a
9621+ [=namespace=].
9622+
96039623See [[#interface-prototype-object]]
96049624for the specific requirements that the use of
96059625[{{Unscopable}}] entails.
@@ -10457,12 +10477,12 @@ The characteristics of this property are as follows:
1045710477<div algorithm>
1045810478
1045910479 The <dfn id="dfn-attribute-getter" export>attribute getter</dfn> is created as follows, given an
10460- [=attribute=] |attribute|, an [=interface=] |target|, and a [=Realm=] |realm|:
10480+ [=attribute=] |attribute|, a [=namespace=] or [=interface=] |target|, and a [=Realm=] |realm|:
1046110481
1046210482 1. Let |steps| be the following series of steps:
1046310483 1. Try running the following steps:
1046410484 1. Let |O| be <emu-val>null</emu-val>.
10465- 1. If |attribute| is a [=regular attribute=]:
10485+ 1. If |target| is an [=interface=], and | attribute| is a [=regular attribute=]:
1046610486 1. If the <emu-val>this</emu-val> value is <emu-val>null</emu-val> or
1046710487 <emu-val>undefined</emu-val>, set |O| to |realm|'s [=Realm/global object=].
1046810488 (This will subsequently cause a <emu-val>TypeError</emu-val> in a few steps, if
@@ -12371,6 +12391,12 @@ The characteristics of a namespace object are described in [[#namespace-object]]
1237112391
1237212392 1. Let |namespaceObject| be
1237312393 [=!=] [=ObjectCreate=](the [=%ObjectPrototype%=] of |realm|).
12394+ 1. For each [=exposed=] [=regular attribute=] |attr| that is a [=namespace member=] of this namespace,
12395+ 1. Let |F| be the result of creating an [=attribute getter=]
12396+ given |attr|, |namespace|, and |realm|.
12397+ 1. Let |newDesc| be the PropertyDescriptor{\[[Get]]: |F|, \[[Enumerable]]: <emu-val>true</emu-val>,
12398+ \[[Configurable]]: <emu-val>true</emu-val>}.
12399+ 1. Perform [=!=] [=DefinePropertyOrThrow=](|namespaceObject|, |attr|'s [=identifier=], |newDesc|).
1237412400 1. For each [=exposed=] [=regular operation=] |op| that is a [=namespace member=] of this namespace,
1237512401 1. Let |F| be the result of [=creating an operation function|creating an operation function=]
1237612402 given |op|, |namespace|, and |realm|.
0 commit comments