Skip to content

Commit 4387065

Browse files
committed
Introduce enumerated attribute reflection IDL
- [ReflectEnum=identifier] can be used alongside [Reflect] on DOMString and DOMString? attributes to identify the IDL enum which holds the known value keywords. Additionally, 3 new extended attributes are allowed on enums: - [InvalidValueDefault] and [InvalidValueDefault=string] sets the value to be used when the content attribute has an invalid value. - [MissingValueDefault] and [MissingValueDefault=string] sets the value to be used when the content attribute is missing. - [EmptyValueDefault] and [EmptyValueDefault=string] sets the value to be used when the content attribute is the empty string.
1 parent df8b74c commit 4387065

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

source

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8816,9 +8816,11 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
88168816
<dfn extended-attribute data-lt="ReflectPositiveWithFallback"
88178817
data-x="xattr-ReflectPositiveWithFallback"><code>[ReflectPositiveWithFallback]</code></dfn>, <dfn
88188818
extended-attribute data-lt="ReflectRange"
8819-
data-x="xattr-ReflectRange"><code>[ReflectRange]</code></dfn>, and <dfn extended-attribute
8820-
data-lt="ReflectDefault" data-x="xattr-ReflectDefault"><code>[ReflectDefault]</code></dfn> IDL
8821-
<span>extended attribute</span>s.</p>
8819+
data-x="xattr-ReflectRange"><code>[ReflectRange]</code></dfn>, <dfn extended-attribute
8820+
data-lt="ReflectDefault" data-x="xattr-ReflectDefault"><code>[ReflectDefault]</code></dfn>, and
8821+
<dfn extended-attribute data-lt="ReflectEnum"
8822+
data-x="xattr-ReflectEnum"><code>[ReflectEnum]</code></dfn> IDL <span>extended
8823+
attribute</span>s.</p>
88228824

88238825
<p>The <code data-x="xattr-Reflect">[Reflect]</code>, <code
88248826
data-x="xattr-ReflectURL">[ReflectURL]</code> <code
@@ -8889,6 +8891,33 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
88898891
<span>extended attribute</span> have a <span>default value</span> provided by <code
88908892
data-x="xattr-ReflectDefault">[ReflectDefault]</code>.</p>
88918893

8894+
<p>The <code data-x="xattr-ReflectEnum">[ReflectEnum]</code> <span>extended attribute</span> must
8895+
take an identifier. It must not appear on anything other than an interface member attribute with a
8896+
type of <code data-x="idl-DOMString">DOMString</code>. Additionally, it must also only appear
8897+
alongside <code data-x="xattr-Reflect">[Reflect]</code>. The identifier provided by <code
8898+
data-x="xattr-ReflectEnum">[ReflectEnum]</code> must be that of an IDL enum, this is used to
8899+
represent the known-value keywords.
8900+
8901+
<p>To declare the value used for the <span>invalid value default</span>, <span>missing value
8902+
default</span>, and the empty value states, we introduce the <dfn extended-attribute
8903+
data-x="xattr-InvalidValueDefault"><code>[InvalidValueDefault]</code></dfn>, <dfn
8904+
extended-attribute data-x="xattr-MissingValueDefault"><code>[MissingValueDefault]</code></dfn>,
8905+
and <dfn extended-attribute
8906+
data-x="xattr-EmptyValueDefault"><code>[EmptyValueDefault]</code></dfn> IDL <span>extended
8907+
attribute</span>s.</p>
8908+
8909+
<p>The <code data-x="xattr-InvalidValueDefault">[InvalidValueDefault]</code>, <code
8910+
data-x="xattr-MissingValueDefault">[MissingValueDefault]</code> and <code
8911+
data-x="xattr-EmptyValueDefault">[EmptyValueDefault]</code> <span>extended attribute</span>s must
8912+
either take no arguments, or take a string. They must not appear on anything other than an
8913+
enum.</p>
8914+
8915+
<p>IDL attributes with the <code data-x="xattr-ReflectEnum">[ReflectEnum]</code> <span>extended
8916+
attribute</span> are <span>limited to only known values</span>.</p>
8917+
8918+
<p>TODO: Define how [InvalidValueDefault], [MissingValueDefault], and [EmptyValueDefault] actually
8919+
work.</p>
8920+
88928921
<h4>Using reflect in specifications</h4>
88938922

88948923
<p><span data-x="reflect">Reflection</span> is primarily about improving web developer ergonomics
@@ -12034,7 +12063,14 @@ interface <dfn interface>HTMLElement</dfn> : <span>Element</span> {
1203412063
undefined <span data-x="dom-showPopover">showPopover</span>(optional <span>ShowPopoverOptions</span> options = {});
1203512064
undefined <span data-x="dom-hidePopover">hidePopover</span>();
1203612065
boolean <span data-x="dom-togglePopover">togglePopover</span>(optional (<span>TogglePopoverOptions</span> or boolean) options = {});
12037-
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-popover">popover</span>;
12066+
[<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>, <span data-x="xattr-ReflectEnum">ReflectEnum</span>=<span>PopoverKeywords</span>] attribute DOMString? <dfn attribute for="HTMLElement" data-x="dom-popover">popover</dfn>;
12067+
};
12068+
12069+
[<span data-x="xattr-InvalidValueDefault">InvalidValueDefault</span>=<span data-x="attr-popover-manual">"manual"</span>, <span data-x="xattr-MissingValueDefault">MissingValueDefault</span>, <span data-x="xattr-EmptyValueDefault">EmptyValueDefault</span>=<span data-x="attr-popover-auto">"auto"</span>]
12070+
enum <dfn enum>PopoverKeywords</dfn> {
12071+
<dfn attr-value for="html-global/popover" data-x="attr-popover-auto">"auto"</dfn>,
12072+
<dfn attr-value for="html-global/popover" data-x="attr-popover-manual">"manual"</dfn>,
12073+
<dfn attr-value for="html-global/popover" data-x="attr-popover-hint">"hint"</dfn>
1203812074
};
1203912075

1204012076
dictionary <dfn dictionary>ShowPopoverOptions</dfn> {
@@ -86323,23 +86359,20 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8632386359
<th>Brief description
8632486360
<tbody>
8632586361
<tr>
86326-
<td><dfn attr-value for="html-global/popover"><code
86327-
data-x="attr-popover-auto">auto</code></dfn>
86328-
<td rowspan=2><dfn data-x="attr-popover-auto-state">Auto</dfn>
86362+
<td><code data-x="attr-popover-auto">auto</code></td>
86363+
<td rowspan=2><dfn data-x="attr-popover-auto-state">Auto</dfn></td>
8632986364
<td rowspan=2>Closes other popovers when opened; has <span data-x="popover light dismiss">light
8633086365
dismiss</span> and responds to <span data-x="close request">close requests</span>.
8633186366
<tr>
8633286367
<td>(the empty string)
8633386368
<tr>
86334-
<td><dfn attr-value for="html-global/popover"><code
86335-
data-x="attr-popover-manual">manual</code></dfn>
86336-
<td><dfn data-x="attr-popover-manual-state">Manual</dfn>
86369+
<td><code data-x="attr-popover-manual">manual</code></td>
86370+
<td><dfn data-x="attr-popover-manual-state">Manual</dfn></td>
8633786371
<td>Does not close other popovers; does not <span data-x="popover light dismiss">light
8633886372
dismiss</span> or respond to <span data-x="close request">close requests</span>.
8633986373
</tr>
8634086374
<tr>
86341-
<td><dfn attr-value for="html-global/popover"><code
86342-
data-x="attr-popover-hint">hint</code></dfn></td>
86375+
<td><code data-x="attr-popover-hint">hint</code></td>
8634386376
<td><dfn data-x="attr-popover-hint-state">Hint</dfn></td>
8634486377
<td>Closes other hint popovers when opened, but not other auto popovers; has <span
8634586378
data-x="popover light dismiss">light dismiss</span> and responds to <span data-x="close
@@ -86353,10 +86386,6 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8635386386
default">invalid value default</i> is the <span data-x="attr-popover-manual-state">Manual</span>
8635486387
state.</p>
8635586388

86356-
<p>The <dfn attribute for="HTMLElement"><code data-x="dom-popover">popover</code></dfn> IDL
86357-
attribute must <span>reflect</span> the <span data-x="attr-popover">popover</span> attribute,
86358-
<span>limited to only known values</span>.</p>
86359-
8636086389
<p>Every <span data-x="HTML elements">HTML element</span> has a <dfn export>popover visibility
8636186390
state</dfn>, initially <span data-x="popover-hidden-state">hidden</span>, with these potential
8636286391
values:</p>

0 commit comments

Comments
 (0)