Skip to content

Commit 3dd29ae

Browse files
committed
Define base appearance for <select>
1 parent 34adbed commit 3dd29ae

File tree

1 file changed

+192
-3
lines changed

1 file changed

+192
-3
lines changed

source

+192-3
Original file line numberDiff line numberDiff line change
@@ -3335,7 +3335,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
33353335
<dfn data-x="concept-element-custom-element-definition" data-x-href="https://dom.spec.whatwg.org/#concept-element-custom-element-definition">custom element definition</dfn>, and
33363336
<dfn data-x="concept-element-is-value" data-x-href="https://dom.spec.whatwg.org/#concept-element-is-value"><code data-x="">is</code> value</dfn></li>
33373337

3338-
<li><dfn data-x-href="https://dom.spec.whatwg.org/#mutationobserver"><code>MutationObserver</code></dfn> interface and <dfn data-x-href="https://dom.spec.whatwg.org/#mutation-observers">mutation observers</dfn> in general</li>
3338+
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#mutationobserver"><code>MutationObserver</code></dfn> interface</li>
3339+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#mutation-observers">Mutation observers</dfn> in general</li>
3340+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#concept-mo-callback">Mutation observer callback</dfn></li>
3341+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserver-observe">Mutation observer observe algorithm</dfn></li>
3342+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserver-disconnect">Mutation observer disconnect algorithm</dfn></li>
3343+
<li><dfn data-x-href="https://dom.spec.whatwg.org/#dom-mutationobserver-disconnect"><code>MutationObserverInit</code></dfn></li>
3344+
<li><dfn data-x="mo childList" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-childlist"><code>childList</code></dfn></li>
3345+
<li><dfn data-x="mo characterData" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-characterdata"><code>characterData</code></dfn></li>
3346+
<li><dfn data-x="mo subtree" href="https://dom.spec.whatwg.org/#dom-mutationobserverinit-subtree"><code>subtree</code></dfn></li>
33393347
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortcontroller"><code>AbortController</code></dfn> and its
33403348
<dfn data-x="concept-AbortController-signal" data-x-href="https://dom.spec.whatwg.org/#abortcontroller-signal">signal</dfn></li>
33413349
<li><dfn data-x-href="https://dom.spec.whatwg.org/#abortsignal"><code>AbortSignal</code></dfn></li>
@@ -3976,6 +3984,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
39763984
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#widget">widget</dfn></li>
39773985
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#native-appearance">native appearance</dfn></li>
39783986
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#primitive-appearance">primitive appearance</dfn></li>
3987+
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#base-appearance">base appearance</dfn></li>
39793988
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size">element with default preferred size</dfn></li>
39803989
<li>The <dfn data-x-href="https://drafts.csswg.org/css-ui/#non-devolvable">non-devolvable widget</dfn> and
39813990
<dfn data-x-href="https://drafts.csswg.org/css-ui/#devolvable">devolvable widget</dfn> classification, and the related
@@ -53970,7 +53979,7 @@ interface <dfn interface>HTMLDataListElement</dfn> : <span>HTMLElement</span> {
5397053979
element <span>represents</span> nothing<span w-nodev> and it, along with its children, should
5397153980
be hidden</span>.</p>
5397253981

53973-
<p>The <code>datalist</code> element can be used in two ways. In the simplest case, the
53982+
<p>The <code>datalist</code> element can be used in three ways. In the simplest case, the
5397453983
<code>datalist</code> element has just <code>option</code> element children.</p>
5397553984

5397653985
<div class="example">
@@ -54010,6 +54019,22 @@ interface <dfn interface>HTMLDataListElement</dfn> : <span>HTMLElement</span> {
5401054019

5401154020
</div>
5401254021

54022+
<p>In the third case, the <code>datalist</code> element can be used as a <code
54023+
data-x="attr-popover">popover</code> for <code>select</code> elements which are being rendered as
54024+
a <span>drop-down box</span> with <span>base appearance</span> when inserted as a child of the
54025+
<code>select</code>.</p>
54026+
54027+
<div class="example">
54028+
54029+
<pre><code class="html">&lt;select>
54030+
&lt;datalist>
54031+
&lt;option>Cat&lt;/option>
54032+
&lt;option>Dog&lt;/option>
54033+
&lt;/datalist>
54034+
&lt;/select></code></pre>
54035+
54036+
</div>
54037+
5401354038
<p>The <code>datalist</code> element is hooked up to an <code>input</code> element using the <code
5401454039
data-x="attr-input-list">list</code> attribute on the <code>input</code> element.</p>
5401554040

@@ -54267,6 +54292,60 @@ interface <dfn interface>HTMLOptionElement</dfn> : <span>HTMLElement</span> {
5426754292

5426854293
</div>
5426954294

54295+
<p>To get the <dfn>option element ancestor select</dfn> given an <code>option</code>
54296+
<var>option</var>:</p>
54297+
54298+
<ol>
54299+
<li>
54300+
<p>For each <var>ancestor</var> of <var>option</var>'s <span
54301+
data-x="ancestor">ancestors</span>:</p>
54302+
54303+
<ol>
54304+
<li><p>If <var>ancestor</var> is a <code>select</code>, then return
54305+
<var>ancestor</var>.</p></li>
54306+
</ol>
54307+
</li>
54308+
54309+
<li><p>Return null.</p></li>
54310+
</ol>
54311+
54312+
<p><code>option</code> elements each have an <dfn>option element mutation observer</dfn>, which is
54313+
a <code>MutationObserver</code>, initially set to a new <code>MutationObserver</code> with its
54314+
<span>mutation observer callback</span> set to the <span>option element mutation callback</span>
54315+
with the <code>option</code> element provided as an argument.</p>
54316+
54317+
<p>To perform the <dfn>option element mutation callback</dfn>, given an <code>option</code> element
54318+
<var>option</var> and a list <var>recordQueue</var>:</p>
54319+
54320+
<ol>
54321+
<li><p>Let <var>select</var> be the result of running <span>option element ancestor select</span>
54322+
given <var>option</var>.</p></li>
54323+
54324+
<li><p>If <var>select</var> is not null and <var>select</var> is being rendered as a
54325+
<span>drop-down box</span>, then set <var>select</var>'s <span>select fallback
54326+
button text</span> to the value of <var>option</var>'s <span
54327+
data-x="dom-option-label">label</span>.</p></li>
54328+
</ol>
54329+
54330+
<p>The <code>option</code> <span>HTML element insertion steps</span>, given
54331+
<var>insertedOption</var>, are:</p>
54332+
54333+
<ol>
54334+
<li><p>Run the <span>mutation observer observe algorithm</span> given <var>insertedOption</var>'s
54335+
<span>option element mutation observer</span>, <var>insertedOption</var>, and a
54336+
<code>MutationObserverInit</code> with <code data-x="mo characterData">characterData</code> set
54337+
to true, <code data-x="mo childList">childList</code> set to true, and <code data-x="mo
54338+
subtree">subtree</code> set to true.</p></li>
54339+
</ol>
54340+
54341+
<p>The <code>option</code> <span>HTML element removing steps</span>, given
54342+
<var>removedOption</var>, are:</p>
54343+
54344+
<ol>
54345+
<li><p>Run the <span>mutation observer disconnect algorithm</span> given
54346+
<var>removedOption</var>'s <span>option element mutation observer</span>.</p></li>
54347+
</ol>
54348+
5427054349
<dl class="domintro">
5427154350
<dt><code data-x=""><var>option</var>.<span subdfn data-x="dom-option-selected">selected</span></code></dt>
5427254351

@@ -135534,12 +135613,122 @@ progress { appearance: auto; }</code></pre>
135534135613
with the element's <code>optgroup</code> element <span data-x="concept-tree-child">children</span>
135535135614
providing headers for groups of options where applicable.</p>
135536135615

135616+
<!-- TODO should parts of this be in form-elements instead of rendering? -->
135617+
135618+
<p><code>select</code> elements which render as a <span>drop-down box</span> support a <span>base
135619+
appearance</span> in addition to <span>native appearance</span> and <span>primitive
135620+
appearance</span>.</p>
135621+
135622+
<p>When a <code>select</code> is being rendered as a <span>drop-down box</span> with a <span>base
135623+
appearance</span>, it is expected to render as if it has the following <span>shadow
135624+
root</span>:</p>
135625+
135626+
<pre><code class="html" data-x=""><slot id="select-button-slot">
135627+
<button id="select-fallback-button">
135628+
<span id="select-fallback-button-text"></span>
135629+
</button>
135630+
</slot>
135631+
<slot id="select-datalist-slot">
135632+
<datalist id="select-fallback-datalist">
135633+
<slot id="select-datalist-options-slot"></slot>
135634+
</datalist>
135635+
</slot></code></pre>
135636+
135637+
<p class="note">Since <span>base appearance</span> is determined by computing style, it isn't
135638+
possible to swap this DOM structure when switching appearance. Implementations can always include
135639+
the DOM structure for <span>base appearance</span> when the <code>select</code> is rendered as a
135640+
<span>drop-down box</span> and then choose to include or exclude it from the layout tree in order
135641+
to control whether it gets rendered or not.</p>
135642+
135643+
<p><code>select</code> elements rendered as a <span>drop-down box</span> with <span>base
135644+
appearance</span> each contain the following elements as shown with ID attributes in the above
135645+
HTML:</p>
135646+
135647+
<!-- TODO is it OK for me to use <ul>, <li>, and <p> like this even though it isn't an
135648+
algorithm? -->
135649+
<ul>
135650+
<li><p>A <dfn>select button slot</dfn>, which is a <code>slot</code>.</p></li>
135651+
135652+
<li><p>A <dfn>select fallback button</dfn>, which is a <code>button</code>.</p></li>
135653+
135654+
<li><p><dfn>Select fallback button text</dfn>, which is a <code>span</code>.</p></li>
135655+
135656+
<li><p>A <dfn>select datalist slot</dfn>, which is a <code>slot</code>.</p></li>
135657+
135658+
<!-- TODO update <datalist> spec for content model and rendering? also popover behavior -->
135659+
<li><p>A <dfn>select fallback datalist</dfn>, which is a <code>datalist</code>.</p></li>
135660+
135661+
<li><p>A <dfn>select datalist options slot</dfn>, which is a <code>slot</code>.</p></li>
135662+
</ul>
135663+
135664+
<p>The <span>shadow root</span> used for <code>select</code>'s <span>drop-down box</span>
135665+
<span>base appearance</span> must have its <span>slot assignment</span> set to "<code
135666+
data-x="">manual</code>" and its <span>delegates focus</span> set to true.</p>
135667+
135668+
<p class="note">Without <span>delegates focus</span> set to true, the <code>select</code> itself
135669+
would receive focus instead of the <code>button</code> which is slotted into the <span>select
135670+
button slot</span>.</p>
135671+
135672+
<p><code>select</code> elements rendered as a <span>drop-down box</span> with <span>base
135673+
appearance</span> must render as if they are using <span>manual slot assignment</span> with the
135674+
following <dfn>base select slotting algorithm</dfn> to <span data-x="assign a slot">assign</span>
135675+
their child nodes to slots. To perform the <span>base select slotting algorithm</span>, given a
135676+
<code>select</code> element <var>select</var>:</p>
135677+
135678+
<ol>
135679+
<li><p>Let <var>firstButton</var> be null.</p></li>
135680+
135681+
<li><p>Let <var>firstDatalist</var> be null.</p></li>
135682+
135683+
<li><p>Let <var>otherChildren</var> be « ».</p></li>
135684+
135685+
<li>
135686+
<p><span data-x="list iterate">For each</span> <code>Node</code> <var>child</var> in
135687+
<var>select</var>'s <span data-x="concept-tree-child">children</span>:</p>
135688+
135689+
<ol>
135690+
<li>
135691+
<p>If <var>child</var> is a <code>button</code>:</p>
135692+
135693+
<ol>
135694+
<li><p>If <var>firstButton</var> is null, then set <var>firstButton</var> to
135695+
<var>child</var>.</p></li>
135696+
</ol>
135697+
</li>
135698+
135699+
<li>
135700+
<p>If <var>child</var> is a <code>datalist</code>:</p>
135701+
135702+
<ol>
135703+
<li><p>If <var>firstDatalist</var> is null, then set <var>firstDatalist</var> to
135704+
<var>child</var>.</p></li>
135705+
</ol>
135706+
</li>
135707+
135708+
<li><p><span data-x="list append">Append</span> <var>child</var> to
135709+
<var>otherChildren</var>.</p></li>
135710+
</ol>
135711+
</li>
135712+
135713+
<li><p>Set <var>select</var>'s <span>select button slot</span>'s <span>manually assigned
135714+
nodes</span> to <var>firstButton</var>.</p></li>
135715+
135716+
<li><p>Set <var>select</var>'s <span>select datalist slot</span>'s <span>manually assigned
135717+
nodes</span> to <var>firstDatalist</var>.</p></li>
135718+
135719+
<li><p>Set <var>select</var>'s <span>select datalist options slot</span>'s <span>manually
135720+
assigned nodes</span> to <var>otherChildren</var>.</p></li>
135721+
</ol>
135722+
135537135723
<p>An <code>optgroup</code> element is expected to be rendered by displaying the element's <code
135538135724
data-x="attr-optgroup-label">label</code> attribute.</p>
135539135725

135540135726
<p>An <code>option</code> element is expected to be rendered by displaying the element's <span
135541135727
data-x="concept-option-label">label</span>, indented under its <code>optgroup</code> element if it
135542-
has one.</p>
135728+
has one. If the <code>option</code> is being rendered in a <code>select</code> which is being
135729+
rendered as a <span>drop-down box</span> with <span>base appearance</span>, then the
135730+
<code>option</code> is expected to render all of its children rather than by displaying its <span
135731+
data-x="concept-option-label">label</span>.</p>
135543135732

135544135733
<p>Each sequence of one or more child <code>hr</code> element siblings may be rendered as a single
135545135734
separator.</p>

0 commit comments

Comments
 (0)