Skip to content

Make <option> and <optgroup> share a text content algorithm#12232

Open
annevk wants to merge 1 commit intomainfrom
annevk/option-optgroup-parity
Open

Make <option> and <optgroup> share a text content algorithm#12232
annevk wants to merge 1 commit intomainfrom
annevk/option-optgroup-parity

Conversation

@annevk
Copy link
Member

@annevk annevk commented Mar 6, 2026

This also fixes several other issues:

  1. Since the current text cares about all legend element children, we want the first legend element child. Not the first child if it is a legend element.
  2. offers replacement text and as such adding spaces on both sides is wrong.
  3. When includeAltText is false we still want to skip the descendants of img elements.

This does not fix an existing issue which is that user agents should be allowed to render the img elements as well if they want to.

  • At least two implementers are interested (and none opposed):
    • WebKit
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
  • Corresponding HTML AAM & ARIA in HTML issues & PRs: N/A, presumably already covered
  • MDN issue is filed: N/A
  • The top of this comment includes a clear commit message to use.

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


/form-elements.html ( diff )
/rendering.html ( diff )

This also fixes several other issues:

1. Since the current text cares about all legend element children, we want the first legend element child. Not the first child if it is a legend element.
2. <img alt> offers replacement text and as such adding spaces on both sides is wrong.
3. When includeAltText is false we still want to skip the descendants of img elements.

This does not fix an existing issue which is that user agents should be allowed to render the img elements as well if they want to.
@annevk annevk requested review from josepharhar and mfreed7 March 6, 2026 14:49
@annevk annevk added the topic: select The <select> element label Mar 6, 2026
@josepharhar
Copy link
Contributor

Not the first child if it is a legend element.

The content model of the optgroup element only allows a legend if it is the first child though, right?

Otherwise this change looks ok to me

@annevk
Copy link
Member Author

annevk commented Mar 10, 2026

The content model has no bearing on browsers. However, it seems that in #12199 we are thinking of changing the standard to require that only the first element child is checked for being a legend element in which case this also needs to change.

So I guess I'll wait with this to see how your experiment pans out and if it pans out favorably I will update the text.

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.

2 participants