-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Define the <selectedcontent>
element
#10633
base: main
Are you sure you want to change the base?
Conversation
The `<selectedoption>` element is part of the customizable `<select>` proposal: whatwg#9799 It allows authors to declaratively clone the contents of the currently selected `<option>` of a `<select>` and style it independently for use in a base appearance `<select>`'s button. The timing of cloning has been discussed here: whatwg#10520 The selectedoption element has been discussed generally here: w3c/csswg-drafts#10242
It seems this is missing a lot of the boilerplate that new elements normally have as well as changes to content models, indexes, etc. See also this checklist at the top of
|
I recreated the [original PR](w3c/html-aam#566) by @josepharhar The `<selectedoption>` element is part of the [customizable select feature](whatwg/html#9799) and is being added to HTML [here](whatwg/html#10633). ## Implementation * WPT tests: web-platform-tests/wpt#45096 * Implementations (link to issue or when done, link to commit): * WebKit: TODO * Gecko: TODO * Blink: https://chromium.googlesource.com/chromium/src/+/18b5eac27b14b409503aa8047cf9358082a0e0df Co-authored-by: Joey Arhar @josepharhar
Thanks!
|
This still seems incomplete. Where does the |
Thanks, I updated the content model of the button element |
<selectedoption>
element<selectedcontent>
element
source
Outdated
@@ -53198,6 +53201,8 @@ You cannot submit this form when the field is incorrect.</samp></pre> | |||
<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> | |||
<dd>If the element is the first child of a <code>select</code> element, then it may 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.
This does not seem accurate as it may also have other content in such cases, right? Otherwise, what would be the point of this 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.
Yes, the previous line about phrasing content also applies so that you can have phrasing content and a selectedcontent element. I added the word "also" to make this more clear. I could also combine this with the previous <dd>
, what do you think?
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 in element definitions thus far the dd
elements are mutually exclusive. Not additive.
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 combined it with the above dd
source
Outdated
<p>then for each <var>selectedcontent</var> of <var>option</var>'s <span>option element | ||
ancestor select</span>'s <span>select descendant selectedcontent elements</span>, run | ||
<span>clone an option into a selectedcontent</span> given <var>option</var> and | ||
<var>selectedcontent</var>.</p> |
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.
If we only support a single selectedcontent
element, why do 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.
It isn't my goal to support multiple selectedcontent elements, and I don't know of a use case for multiple.
I like maintaining a list of descendant selectedcontent elements because it avoids the need to traverse through all the descendants of the select element to find another selectedcontent element in the case that a selectedcontent element is removed.
Now that I think about it, I'm probably OK with just performing a clone into the first selectedoption element in this list. I updated the text to take the first element from the list and added logic in some other places to make sure that only the first inserted selectedcontent element is kept up to date.
source
Outdated
<p>Every time the selected <code>option</code> of a <code>select</code> switches from one option | ||
to another, the <code>selectedcontent</code> element removes all of its children and replaces them | ||
with a new cloned copy of the DOM structure of the <code>select</code>'s selected | ||
<code>option</code> element.</p> |
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 worry that implementers will look at this and not implement the actual algorithm. Perhaps we can make this web developer edition only or turn it into a note or something?
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 the w-dev
attribute to the <p>
. How does that look?
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.
Nothing major except I'm concerned about using selectedcontent element's insertion steps instead of post-connection steps. This is because I believe the steps as currently specified can run script, and script must not run during an element's insertion steps.
source
Outdated
|
||
<li><p><span data-x="list append">Append</span> <var>selectedcontent</var> to | ||
<var>nearestSelectAncestor</var>'s <span>select descendant selectedcontent | ||
elements</span>.</p></li> |
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 guess this is related to Anne's question above, but do we support multiple selectedcontent
elements or no?
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.
In response to that comment I added logic to only support one selectedcontent element, but I still want to keep this list in order to prevent adding even more logic
I just added a "disabled" concept to help prevent infinite loops during cloning due to putting a selectedcontent element inside multiple select elements, another selectedcontent element, or an option element. |
I made the select.value and select.selectedIndex setters trigger cloning to follow this resolution: openui/open-ui#1119 (comment) |
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.
A few comments from looking at parts of this:
In response to feedback from @dbaron, I made the one selectedcontent element which receives updates be the first one in tree order instead of the first one to be inserted. I also removed the select descendant selectedoption elements list. |
Since we are only planning to support one <selectedcontent> element in <select>, this patch only performs a clone into the first <selectedcontent> in tree order. This is in response to feedback here: whatwg/html#10633 (comment) This patch also removes the logic which clears <selectedcontent> elements when they are removed/disconnected. Change-Id: I1580ec9f12df463d1f5134905e3e527cfefa694d
Since we are only planning to support one <selectedcontent> element in <select>, this patch only performs a clone into the first <selectedcontent> in tree order. This is in response to feedback here: whatwg/html#10633 (comment) This patch also removes the logic which clears <selectedcontent> elements when they are removed/disconnected. Change-Id: I1580ec9f12df463d1f5134905e3e527cfefa694d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6043186 Reviewed-by: David Baron <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1399301}
Since we are only planning to support one <selectedcontent> element in <select>, this patch only performs a clone into the first <selectedcontent> in tree order. This is in response to feedback here: whatwg/html#10633 (comment) This patch also removes the logic which clears <selectedcontent> elements when they are removed/disconnected. Change-Id: I1580ec9f12df463d1f5134905e3e527cfefa694d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6043186 Reviewed-by: David Baron <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1399301}
The
<selectedcontent>
element is part of the customizable<select>
proposal: #9799It allows authors to declaratively clone the contents of the currently selected
<option>
of a<select>
and style it independently for use in a base appearance<select>
's button.The timing of cloning has been discussed here:
#10520
The selectedcontent element has been discussed generally here: w3c/csswg-drafts#10242
html-aria PR: w3c/html-aria#528
html-aam PR: w3c/html-aam#566
(See WHATWG Working Mode: Changes for more details.)
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interactive-elements.html ( diff )
/parsing.html ( diff )