-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Define customizable <select>
#10548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Define customizable <select>
#10548
Conversation
8be5f47
to
0bee650
Compare
4691e13
to
bef9083
Compare
34be830
to
fed19dc
Compare
FYI: I am likely going to remove the author-provided datalist and fallback UA button in this PR soon based on recent discussions, which will likely reduce the number of changes and complexity. |
6dab95d
to
57e00bf
Compare
50bf192
to
12edc88
Compare
Should this PR be closed, to avoid confusion? I believe it's been completely superseded by the list at the top of #9799, right? |
Yes I'm not keeping this up to date anymore since I decided to split out the PRs and have slight redundancies |
12edc88
to
e556826
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found two more small issues, but overall this looks good. In the future I'd prefer the occasional rebase and force push over merge commits. It feels very uncertain whether these 179 commits once squashed will have unintended consequences. Hopefully there are none.
@josepharhar I suggest you prepare this PR for landing, superseding the others. The commit message should explain the change and cause the other PRs to get closed.
@smaug---- any more comments from your side?
@domenic @domfarolino are you both happy with the state of this?
source
Outdated
<dt><span data-x="concept-element-content-model">Content model</span>:</dt> | ||
<dd><span>Phrasing content</span>, but there must be no <span>interactive content</span> | ||
descendant and no descendant with the <code data-x="attr-tabindex">tabindex</code> attribute | ||
specified.</dd> | ||
specified. If the element is the first child of a <code>select</code> element, then it may also | ||
have zero or one <code>selectedcontent</code> element.</dd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ambiguous with respect to whether this is allowed as child or descendant and how this relates to phrasing content. Maybe @zcorpan has ideas on how to best phrase this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added "descendant" to try making it less ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the area element, the following is more preferable.
4.10.17 The selectedcontent element
Categories:
Phrasing content.
Contexts in which this element can be used:
Where phrasing content is expected, but only if there is, in ancestor, button element which is a child of a select element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you're saying that we should add the selectedcontent element to the phrasing content category? How come?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<select>
<button><span><selectedcontent></selectedcontent></span></button>
<option>option1</option>
</select>
The above is non-conformance.
Because, currently, span element cannot have selectedcontent element.
Then,it is meaningless that button element can contain selectedcontent element as a descendant(not child).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I added the selectedcontent element to phrasing content
<select>
<select>
Done, thanks! |
source
Outdated
<dd>If the element has no <code data-x="attr-option-label">label</code> attribute and is a child | ||
of a <code>datalist</code> element: <span data-x="text content">Text</span>.</dd> | ||
child of a <code>datalist</code> element: Zero or more <span><code>option</code> element | ||
inner content elements</span>.</dd> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following is conformance?
<label> Animal:<input name=animal list=animals></label>
<datalist id=animals>
<label>or select from the list:
<select name=animal>
<option><img src="cat.jpg" alt="cat"></option>
<option><div>dog<br><small>(but except child dog)</small></div></option>
</select>
</label>
</datalist>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The option element is not a child of a datalist element, so it falls into the "zero or more option element inner content elements" case, so it's allowed to have the child img and div in your example. Does that answer your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When such option element is displayed as suggestion by datalist element, how is it rendered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input element's datalist does not support rendering things other than text right now, so it just renders the text content of the option.
The spec does not say anything in the rendering section about inputs with datalist.
I also find it very odd that the spec says that datalists can have phrasing content which technically allows for having a select inside of a datalist. In my opinion this should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's intentional I think. As that's the graceful degradation story for user agents that do not support datalist
(you would get two controls instead of one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The browser which support customizable select element and dosen't support datalist element will be probably extremely rare.
Therefore, the content model of option element(which has no label attribute) as "descendant" of a datalist element should be text only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok we could change the "child of a datalist" cases to "descendant of a datalist", but it seems kinda of contradictory since right above that it says that options are allowed as children of a datalist element as opposed to allowing them as descendants of a datalist element. Should we change that too to say that options are allowed as descendants of datalist elements?
Or we could just keep it as-is and say that your example is conformance. I anticipate that similar changes to option elements will happen in the future for the datalist element so that we can do base appearance for <input type=text>
with <datalist>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok we could change the "child of a datalist" cases to "descendant of a datalist", but it seems kinda of contradictory since right above that it says that options are allowed as children of a datalist element as opposed to allowing them as descendants of a datalist element. Should we change that too to say that options are allowed as descendants of datalist elements?
Yes, we should change that too to say that options are allowed as descendants of datalist elements.
Only when "customizable datalist" is supported in the future, we will be able to remove the conditioning by presence or absence of ancestor datalist element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more difficult.
You want either phrasing content or option elements. But then the option elements (that could also be part of the phrasing content through a <select>
element) need to be constrained to just text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it would be more ideal to call the example conformance, or to say that datalist elements aren't allowed to have interactive descendants like the select element.
You want either phrasing content or option elements. But then the option elements (that could also be part of the phrasing content through a
<select>
element) need to be constrained to just text.
So I guess we need a way of saying that when an option element is both a descendant of a select element and a descendant of a datalist element at the same time, that the datalist rule takes precedence and the options must have text? I could add a case for it being a descendant of a datalist and a select at the same time.
5e7ad83
to
82a3769
Compare
This defines several concepts related to customizable
<select>
:<select>
<select>
and related elements.<select>
<selectedcontent>
HTML element<select>
with base appearanceCloses #9799
Closes #10557
Closes #10310
Closes #10586
Closes #10317
Closes #10629
Closes #10633
Closes #10520
Closes #10670
Closes #10520
Closes #10762
<select>
parser WebKit/standards-positions#414<select>
parser mozilla/standards-positions#1086/dom.html ( diff )
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/grouping-content.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interactive-elements.html ( diff )
/parsing.html ( diff )
/references.html ( diff )
/rendering.html ( diff )
/scripting.html ( diff )
/text-level-semantics.html ( diff )