Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Define the<selectedcontent> element#10633

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
josepharhar wants to merge47 commits intowhatwg:main
base:main
Choose a base branch
Loading
fromjosepharhar:selectedoption

Conversation

josepharhar
Copy link
Contributor

@josepharharjosepharhar commentedSep 18, 2024
edited by pr-previewbot
Loading

The<selectedcontent> element is part of the customizable<select> proposal:#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.

Some details on the cloning behavior, which were decided on in order to always make sure that the selectedcontent element is up to date and in order to reduce developer confusion:

  • Cloning is done with an algorithm similar to the Node.cloneNode() function.
  • Cloning is done synchronously at these times:
    • When an</option> end tag is parsed during HTML parsing.
    • A selectedcontent element is inserted, during its post-connection steps.
    • Immediately before input and change events are fired on a select element.
    • When the select.selectedIndex IDL is assigned to.

Fixes#10520

The selectedcontent element has been discussed generally here:w3c/csswg-drafts#10242

html-aria PR:w3c/html-aria#528
html-aam PR:w3c/aria#2344

(SeeWHATWG 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 )

faridvatani reacted with thumbs up emoji
The `<selectedoption>` element is part of the customizable `<select>`proposal:whatwg#9799It allows authors to declaratively clone the contents of the currentlyselected `<option>` of a `<select>` and style it independently for usein a base appearance `<select>`'s button.The timing of cloning has been discussed here:whatwg#10520The selectedoption element has been discussed generally here:w3c/csswg-drafts#10242
@annevk
Copy link
Member

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 ofsource:

 !   Adding a new element involves editing the following sections: !    - section for the element itself !    - descriptions of the element's categories !    - images/content-venn.svg !    - syntax, if it's void or otherwise special !    - parser, if it's not phrasing-level !    - rendering !    - obsolete section !    - element, attribute, content model, and interface indices

scottaohara added a commit to w3c/aria that referenced this pull requestSep 27, 2024
I recreated the [original PR](w3c/html-aam#566) by@josepharharThe `<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/+/18b5eac27b14b409503aa8047cf9358082a0e0dfCo-authored-by: Joey Arhar@josepharhar
@josepharhar
Copy link
ContributorAuthor

Thanks!

  • I added a dl with a bunch of metadata for the element itself.
  • I didn't include this element in any categories
  • I didn't update the content-venn image because I didn't add it to any categories.
  • I didn't update syntax or parsing because it doesn't have any special rules and I didn't implement anything in the HTML parser for this.
  • I didn't update rendering because I noticed that elements like<div> and<span> don't have sections in there, and selectedoption is supposed to render like those elements.
  • I didn't update the obsolete section because nothing is becoming obsolete...?
  • I updated the element and interface indexes

@annevk
Copy link
Member

This still seems incomplete. Where does thebutton element indicate this element can be a descendant, for instance? If you don't adjust the categories, you still need to account for how the categories are used.

@josepharhar
Copy link
ContributorAuthor

This still seems incomplete. Where does thebutton element indicate this element can be a descendant, for instance? If you don't adjust the categories, you still need to account for how the categories are used.

Thanks, I updated the content model of the button element

@scottaohara
Copy link
Collaborator

@domfarolino sorry, I missed your mention of me since I've already been mentioned in this thread, github doesn't make it clear when someone has been re-mentioned.

the html aam (2344) PR is waiting on this to merge. It hasn't had any updates since I made some wording changes to a note in February. There are various other HTML AAM PRs related to customizable select which are also ready to go once everything is ready to merge into the HTML spec.

the aria in html pr (528) is essentially ready to go as well. No more spec updates needed, just some issues to file against conformance checkers.

@scottaohara
Copy link
Collaborator

@josepharhar not sure if this is the PR to comment on or not, but per our chat discussion it's probably worth calling out that while<option label=foo> can be used with the customizable select, and will render a visible label for the option in the select's popup - if selected nothing will be returned to theselectedcontent element - since that works by cloning the descendants of the option, and in this care there are none.

Someone can still benefit from broader styling capabilitiesand still define option element label text using the attributeif their customized select does not contain a button part (and thus no selectedcontent element). Maybe it makes sense to call this out? that way, if someone does attempt to use label attributes when defining their options, it's made clear "if you want to do this, then you shouldn't use the button part/selectedconent elements. but, to have greater control, use child content of the option to define your labels, which will also allow for more styling capabilities for represented the selected content in the select's collapsed state.

or you know... word smith as you see fit

@josepharhar
Copy link
ContributorAuthor

Thanks Scott! I added a note here:bcd9669

scottaohara reacted with thumbs up emoji

aarongable pushed a commit to chromium/chromium that referenced this pull requestMay 12, 2025
These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull requestMay 12, 2025
These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull requestMay 12, 2025
These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}
lando-prod-mozillabot pushed a commit to mozilla-firefox/firefox that referenced this pull requestMay 14, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull requestMay 15, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull requestMay 15, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarhar@chromium.org>Reviewed-by: Dominic Farolino <dom@chromium.org>Cr-Commit-Position: refs/heads/main@{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull requestMay 16, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarharchromium.org>Reviewed-by: Dominic Farolino <domchromium.org>Cr-Commit-Position: refs/heads/main{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370UltraBlame original commit: c92c496cf3b9513fb0279fdb8afa468388d866ff
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull requestMay 16, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarharchromium.org>Reviewed-by: Dominic Farolino <domchromium.org>Cr-Commit-Position: refs/heads/main{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370UltraBlame original commit: c92c496cf3b9513fb0279fdb8afa468388d866ff
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull requestMay 16, 2025
…content>,Automatic update from web-platform-testsAdd MutationObserver tests for <selectedcontent>These were requested here:whatwg/html#10633 (comment)There are failing test expectations added for the virtual test suiteswhere CustomizableSelect is disabled, where the <selectedcontent>element is not enabled.Change-Id: Ib2906a5c8d70ae5ea5cccb6d899c79b29ea45e5eReviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6471702Commit-Queue: Joey Arhar <jarharchromium.org>Reviewed-by: Dominic Farolino <domchromium.org>Cr-Commit-Position: refs/heads/main{#1458866}--wpt-commits: 23b9c427c9115a1b40b95e4e4099c353a985c958wpt-pr: 52476Differential Revision:https://phabricator.services.mozilla.com/D249370UltraBlame original commit: c92c496cf3b9513fb0279fdb8afa468388d866ff
@estelle
Copy link

Permdn/content#39411; "Dynamic modifications to the selected<option> element's content made after the<select> element has been created are not automatically cloned to the<selectedcontent> element, and must be manually updated by the developer."

This has usability and security risks. If the option can be updated without the content of the<selectedcontent> updating along with it without JS, this has the likelihood of leading to broken forms. It's also a security risk as the user may submit a form with an unintended value that is not visible due to malicious code.

We don't want to add anything to the web platform that may potentially break things, make a form control less accessible, or add any vulnerabilities.

titoBouzout reacted with thumbs up emojiSacramentix reacted with thumbs down emoji

@mfreed7
Copy link
Contributor

If the option can be updated without the content of the<selectedcontent> updating along with it without JS, this has the likelihood of leading to broken forms.

I don't think this is possible without JS. To get this behavior, youneed JS manipulating the DOM in a very particular way: the<option> contents must be mutated after that<option> is appended to the<select>. If the site is using plain html and css, then<selectedcontent> should "just work" in all cases.

It's also a security risk as the user may submit a form with an unintended value that is not visible due to malicious code.

If the malicious code has DOM access, isn't this already true?

<select id=purchase_quantity>  <option value=1000000> 1 </option></select>

This would submit the value "1000000" even though the user sees "1".

domenic and Sacramentix reacted with thumbs up emoji

@estelle
Copy link

If the site is using plain html and css, then<selectedcontent> should "just work" in all cases.

If the site is using JS, will it ever break the<selectedcontent>? My understanding is that is can, and does.

<selectid=purchase_quantity><optionvalue=1000000> 1</option></select>

while the above is currently and has always been possible, if the following is ever possible, the implementation needs to be fixed:

<selectid=purchase_quantity><button><selectedcontent>1</selectedcontent></button><optionselected> 10</option></select>

This being pseudo-markup: Where "selected" is not necessarily an attribute, but rather the current state

@josepharharjosepharhar mentioned this pull requestJun 11, 2025
5 tasks
@josepharhar
Copy link
ContributorAuthor

This PR won't be merged and will instead be included in a bigger PR including all customizable select PRs:#10548

@titoBouzout
Copy link

An element that modifies the page by adding/removing elements seems like a bad idea.

It will break any code that expects the structure of the html to be the same as it was served.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dbarondbarondbaron left review comments

@domenicdomenicdomenic left review comments

@annevkannevkannevk left review comments

@scottaoharascottaoharascottaohara left review comments

@mfreed7mfreed7mfreed7 left review comments

@domfarolinodomfarolinodomfarolino approved these changes

Assignees
No one assigned
Labels
addition/proposalNew features or enhancementsdo not merge yetPull request must not be merged per rationale in commenttopic: formstopic: selectThe <select> element
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Timing of cloning for the<selectedoption> element
10 participants
@josepharhar@annevk@hsivonen@scottaohara@estelle@mfreed7@titoBouzout@dbaron@domenic@domfarolino

[8]ページ先頭

©2009-2025 Movatter.jp