@@ -2242,24 +2242,23 @@ corresponding argument omitted.
22422242 conversion of <emu-val>undefined</emu-val> to be used (i.e., <emu-val>false</emu-val>).
22432243</p>
22442244
2245- If the type of an argument is a [=dictionary type=] or a [=union type=] that has a dictionary as one
2245+ If the type of an argument is a [=dictionary type=] or a [=union type=] that has
2246+ a [=dictionary type=] as one
22462247of its [=flattened member types=], and that dictionary type and its ancestors have no
22472248[=required dictionary member|required members=], and the argument is either the final argument or is
2248- followed only by [=optional arguments=], then the argument must be specified as optional. Such
2249- arguments are always considered to have a [=optional argument/default value=] of an empty
2250- dictionary, unless otherwise specified.
2249+ followed only by [=optional arguments=], then the argument must be specified as
2250+ optional and have a default value provided.
22512251
22522252<div class="note">
22532253
22542254 This is to encourage API designs that do not require authors to pass an
22552255 empty dictionary value when they wish only to use the dictionary’s
22562256 default values.
22572257
2258- Dictionary types cannot have a default value specified explicitly, so the
2259- “unless otherwise specified” clause above can only be invoked for
2260- a [=union type=] that has a
2261- dictionary type as one of its [=flattened member types=].
2262-
2258+ Usually the default value provided will be <emu-t>{}</emu-t>, but in the
2259+ case of a [=union type=] that has a dictionary type as one of its
2260+ [=flattened member types=] a default value could be provided that
2261+ initializes some other member of the union.
22632262</div>
22642263
22652264When a boolean literal token (<emu-t>true</emu-t> or <emu-t>false</emu-t>),
@@ -2303,13 +2302,20 @@ is an [=enumeration=], then its
23032302be one of the [=enumeration values|enumeration’s values=].
23042303
23052304Optional argument default values can also be specified using the
2306- two token value <code >[]</code >, which represents an empty sequence
2305+ two token value <emu-t >[]</emu-t >, which represents an empty sequence
23072306value. The type of this value is the same as the type of the optional
23082307argument it is being used as the default value of. That type
23092308must be a [=sequence type=], a [=nullable type=] whose [=nullable types/inner type=] is a
23102309[=sequence type=] or a [=union type=] or [=nullable type|nullable=] union type
23112310that has a [=sequence type=] in its [=flattened member types=].
23122311
2312+ Optional argument default values can also be specified using the two token value
2313+ <emu-t>{}</emu-t>, which represents a default-initialized (as if from ES
2314+ <emu-t>null</emu-t> or an object with no properties) dictionary value. The type
2315+ of this value is the same as the type of the optional argument it is being used
2316+ as the default value of. That type must be a [=dictionary type=], or a [=union
2317+ type=] that has a [=dictionary type=] in its [=flattened member types=].
2318+
23132319<div class="example">
23142320
23152321 The following [=IDL fragment=]
@@ -2337,6 +2343,31 @@ that has a [=sequence type=] in its [=flattened member types=].
23372343 </pre>
23382344</div>
23392345
2346+ <div class="example">
2347+
2348+ The following [=IDL fragment=]
2349+ defines an [=interface=]
2350+ with an operation that takes a dictionary argument:
2351+
2352+ <!-- Should be `highlight="webidl"`, but that gives bikeshed conniptions
2353+ because it does not know about the syntax we are introducing -->
2354+ <pre>
2355+ dictionary LookupOptions {
2356+ boolean caseSensitive = true;
2357+ };
2358+
2359+ [Exposed=Window]
2360+ interface AddressBook {
2361+ boolean hasAddressForName(USVString name, optional LookupOptions options = {});
2362+ };
2363+ </pre>
2364+
2365+ If <code>hasAddressForName</code> is called with only one argument, the
2366+ second argument will be a default-initialized <code>LookupOptions</code>
2367+ dictionary, which will cause <code>caseSensitive</code> to be set to
2368+ <emu-t>true</emu-t>.
2369+ </div>
2370+
23402371The following extended attributes are applicable to operations:
23412372[{{Default}}],
23422373[{{Exposed}}],
@@ -2349,6 +2380,7 @@ The following extended attributes are applicable to operations:
23492380 ConstValue
23502381 string
23512382 "[" "]"
2383+ "{" "}"
23522384 "null"
23532385</pre>
23542386
@@ -4524,8 +4556,9 @@ an <emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> token, a
45244556<emu-t class="regex"><a href="#prod-decimal">decimal</a></emu-t> token,
45254557one of the three special floating point literal values (<emu-t>Infinity</emu-t>,
45264558<emu-t>-Infinity</emu-t> or <emu-t>NaN</emu-t>),
4527- a <emu-t class="regex"><a href="#prod-string">string</a></emu-t> token or
4528- the two token sequence <emu-t>[]</emu-t> used as the
4559+ a <emu-t class="regex"><a href="#prod-string">string</a></emu-t> token, the two
4560+ token sequence <emu-t>[]</emu-t>, or the two token sequence <emu-t>{}</emu-t> is
4561+ used as the
45294562[=dictionary member/default value=],
45304563it is interpreted in the same way as for an [=operation=]’s
45314564[=optional argument/default value|optional argument default value=].
0 commit comments