Skip to content
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

Update content model for customizable select #10586

Open
wants to merge 45 commits into
base: main
Choose a base branch
from

Conversation

josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Aug 28, 2024

This PR updates the content model for the <select>, <option>, and <optgroup> elements in support of customizable <select>.

The major additions are:

  • <select> and <optgroup> can contain <div> elements.
  • <option> elements can contain <div> and non-interactive phrasing content.
  • <optgroup> can have a child <legend> to represent its label.

Fixes #10317

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff )
/form-elements.html ( diff )
/grouping-content.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/rendering.html ( diff )
/scripting.html ( diff )
/text-level-semantics.html ( diff )

This PR updated the content model for the <select>, <option>, and
<optgroup> elements in support of customizable <select>.

Fixes whatwg#10317
@zcorpan zcorpan self-requested a review September 12, 2024 16:07
@zcorpan
Copy link
Member

zcorpan commented Sep 16, 2024

Is the idea to allow <select><div><h1><option> and such? Or only <select><div><div><option>?

If the former, you need to change the definition of phrasing content to include "option (if it is a descendant of a select element), optgroup (if it is a descendant of a select element)".

If the latter, you need to change the content model if div and span to switch on whether there's an ancestor select element, and if so allow "select element inner content elements". (But still disallow nesting of optgroup and option)

@zcorpan zcorpan mentioned this pull request Sep 16, 2024
5 tasks
@josepharhar
Copy link
Contributor Author

Is the idea to allow <select><div><h1><option> and such? Or only <select><div><div><option>?

If the former, you need to change the definition of phrasing content to include "option (if it is a descendant of a select element), optgroup (if it is a descendant of a select element)".

If the latter, you need to change the content model if div and span to switch on whether there's an ancestor select element, and if so allow "select element inner content elements". (But still disallow nesting of optgroup and option)

h1 elements are not supposed to be part of the content model, so I implemented the div and span switching by pulling out the content models for option and optgroup and using them in div and span.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use some examples. Or are we adding those as part of another PR?

scottaohara added a commit to w3c/aria that referenced this pull request Oct 22, 2024
In regards to the updated content model for the select element and its allowed children, an `optgroup` can have a `legend` element as its first child, and this `legend` needs to be able to name the `optgroup` similarly to how a `legend` names a `fieldset`.

see:
whatwg/html#10586
@josepharhar
Copy link
Contributor Author

This could use some examples. Or are we adding those as part of another PR?

I started a follow up here: https://github.com/whatwg/html/compare/main...josepharhar:html:selectexamples?expand=1

@scottaohara
Copy link
Collaborator

This could use some examples. Or are we adding those as part of another PR?

I started a follow up here: https://github.com/whatwg/html/compare/main...josepharhar:html:selectexamples?expand=1

thanks @josepharhar - give me a shout when these are finished, and i can help review and/or add on as need be.

@josepharhar
Copy link
Contributor Author

In order to resolve the remaining two open comment threads, I added notes about the content model:

I originally had notes about the content model which were placed directly after the content model itself, but I was told not to do that and to put the notes where the prose about the content model is. I'm not sure where such prose exists, so I just added the notes to the very end of the option element and select element sections: #10586 (comment)

Copy link
Member

@domfarolino domfarolino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like everything has been addressed with this PR for a bit now. The contents look good to me, thanks for resolving the last two bits in #10586 (comment) @josepharhar and adding more detail to the commit message in the OP.

I'll plan on merging this towards the end of next week, provided the one nit I found gets resolved and there are no further substantial reviews.

<code data-x="">" "</code>, the value of <span>descendant</span>'s <code
data-x="attr-img-alt">alt</code> attribute, and <code data-x="">" "</code>.</p></li>

<li><p><span>Continue</span> skipping all <span data-x="descendant">>descendants</span> of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li><p><span>Continue</span> skipping all <span data-x="descendant">>descendants</span> of
<li><p><span>Continue</span> skipping all <span data-x="descendant">descendants</span> of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: select The <select> element
Development

Successfully merging this pull request may close these issues.

Content model and 'what' to render for stylable <select> elements
8 participants