-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Define optgroup base appearance rendering #12201
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?
Changes from 5 commits
c34b79c
c33f02c
5fd0dc6
dacd338
919c0ab
918c8ce
f5571b4
55e38c7
23f2425
7c84a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148350,8 +148350,37 @@ progress { appearance: auto; }</code></pre> | |
| <p>The <span>'::checkmark'</span> pseudo-element only applies to <code>option</code> elements | ||
| which are <span data-x="option-base-appearance">being rendered with base appearance</span>.</p> | ||
|
|
||
| <p>An <code>optgroup</code> element is <span>expected</span> to be rendered by displaying the | ||
| element's <code data-x="attr-optgroup-label">label</code> attribute.</p> | ||
| <p>An <code>optgroup</code> element is <dfn data-x="optgroup-base-appearance">rendered with base | ||
| appearance</dfn> if it has an <span>ancestor</span> <code>select</code> element, and the nearest | ||
| <span>ancestor</span> <span><code>select</code>'s <code>option</code>s are being rendered with | ||
| base appearance</span>.</p> | ||
|
|
||
| <p>If an <code>optgroup</code> element is not being <span | ||
| data-x="optgroup-base-appearance">rendered with base appearance</span>, then it is | ||
| <span>expected</span> to be rendered by displaying the element's <span | ||
| data-x="concept-optgroup-label">label</span>.</p> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we're not fixing this here we should add an XXX marker as this is clearly broken.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, i added an XXX |
||
|
|
||
| <p>If an <code>optgroup</code> element is being <span data-x="optgroup-base-appearance">rendered | ||
| with base appearance</span>, then it is <span>expected</span> to render with a <span>shadow | ||
| tree</span> that contains the following elements:</p> | ||
|
|
||
| <ol> | ||
| <li><p>An <dfn>optgroup legend slot</dfn>, which is a <code>slot</code> element. It is appended | ||
| to the <code>optgroup</code>'s <span>shadow root</span> as the first child. It is | ||
| <span>expected</span> to take the first child element of the <code>optgroup</code> if the first | ||
| child element is a <code>legend</code> element.</p></li> | ||
|
|
||
| <li><p>An <dfn>optgroup label element</dfn>, which is a <code>div</code> element. It is appended | ||
| to the <span>optgroup legend slot</span> as the first child. It is <span>expected</span> to | ||
|
josepharhar marked this conversation as resolved.
Outdated
|
||
| contain a copy of the text in the <code>optgroup</code>'s <code | ||
| data-x="attr-optgroup-label">label</code> attribute.</p></li> | ||
|
|
||
| <li><p>An <dfn>optgroup slot</dfn>, which is a <code>slot</code> element. It is appended to the | ||
|
josepharhar marked this conversation as resolved.
Outdated
|
||
| <code>optgroup</code>'s <span>shadow root</span> after the <span>optgroup label element</span>. | ||
| It is <span>expected</span> to take all child nodes of the <code>optgroup</code> | ||
|
josepharhar marked this conversation as resolved.
Outdated
|
||
| element except for the first child <code>legend</code> element, if present, which is taken by the | ||
| <span>optgroup legend slot</span>.</p></li> | ||
| </ol> | ||
|
|
||
| <div algorithm> | ||
| <p>To determine if a <dfn><code>select</code>'s <code>option</code>s are being rendered with base | ||
|
|
@@ -148375,13 +148404,31 @@ progress { appearance: auto; }</code></pre> | |
| ancestor <code>select</code></span> and the <span><code>select</code>'s <code>option</code>s are | ||
| being rendered with base appearance</span>.</p> | ||
|
|
||
| <p>An <code>option</code> element is <span>expected</span> to be rendered by displaying the result | ||
| of <span>collect option text</span> given the <code>option</code> and true, indented under its | ||
| <code>optgroup</code> element if it has one. If the <code>option</code> <span | ||
| data-x="option-base-appearance">is being rendered with base appearance</span> and the | ||
| <code>option</code>'s <code data-x="attr-option-label">label</code> attribute is not set, then the | ||
| <code>option</code> is <span>expected</span> to render all of its children rather than by | ||
| displaying its <span data-x="concept-option-label">label</span>.</p> | ||
| <p>If an <code>option</code> element is not being <span data-x="option-base-appearance">rendered | ||
| with base appearance</span>, then it is <span>expected</span> to be rendered by displaying the | ||
| result of <span>collect option text</span> given the <code>option</code> and true.</p> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we first have to define what it means for an option element to be rendered with base appearance as base/native appearance isn't a thing for option elements (aiui). So the same order as above for If we also tackle
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So should I add a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That probably has to happen as well then, yes. My preferred solution would be that we just define it as part of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took another look and I'm not sure what the option element is missing that the optgroup element has with regards to base/native appearance in this PR. Could you elaborate on what is missing?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For optgroup we start out with defining what it means to be rendered with base appearance. For instance, we require an ancestor select (though we need to make that more precise so it deals with intermediate hr elements and the like I think). I'm not sure that is sufficient however as these don't really have base appearance through appearance: base. It's a result of nesting, right? So I'm not sure that makes them compatible with the appearance base infra.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what we want is that some things apply universally, such as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense. I took a look at chromium, and the only UA style rule that is applied to option elements in both appearance:auto and appearance:base selects is white-space:nowrap, which maybe is another thing we just need to undo for "base appearance".
Yes, option elements don't support the appearance property. If you think we should rename this definition for options and optgroup elements, I'd be happy to rename it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
WebKit is adding As for the language, maybe something like "option/optgroup elements [with a base appearance select]" and then "with a base appearance select" is defined through the ancestor select element thingy that also handles
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is standardized for base appearance: https://html.spec.whatwg.org/multipage/rendering.html#:~:text=0.5em%3B-,white%2Dspace%3A%20nowrap,-%3B%0A%7D%0A%0Aselect
Thanks, I see that this is about UA styles for options and optgroups when they are outside of a select element, not about base appearance. I'd be supportive of standardizing/changing those styles as long as there aren't compat issues. Maybe that's worth a separate spec issue and PR? I added properties like white-space:nowrap to the base appearance section because I didn't think that we would actually standardize the UA styles for these elements outside of base appearance.
Ok, I used the shared algorithm to find an ancestor select, and I'm still using the shared algorithm which defines when select's contents are rendered with base appearance. How does it look?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this works overall. I think we should probably keep things restricted to the base appearance style sheet if they are not universal, but if we can agree on making them universal we should move them. I think that's the case for |
||
|
|
||
| <p>If an <code>option</code> element is being <span data-x="option-base-appearance">rendered | ||
| with base appearance</span>, then it is <span>expected</span> to render with a <span>shadow | ||
| tree</span> that contains the following elements:</p> | ||
|
|
||
| <ol> | ||
| <li><p>An <dfn>option label element</dfn>, which is a <code>div</code> element. It is appended to | ||
| the <code>option</code>'s <span>shadow root</span> as the first child. It is | ||
| <span>expected</span> to have a text node child containing the value of the <code>option</code>'s | ||
| <code data-x="attr-option-label">label</code> attribute. If the <code>option</code> element does | ||
| not have the <code data-x="attr-option-label">label</code> attribute, or the <code | ||
| data-x="attr-option-label">label</code> is set to an empty string, then the <span>option label | ||
| element</span> is <span>expected</span> to have its <span>'display'</span> property set to | ||
| 'none'.</p></li> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So why not have this as a child of the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I rewrote it to use slot assignment and a fallback instead |
||
|
|
||
| <li><p>An <dfn>option content slot</dfn>, which is a <code>slot</code> element. It is appended to | ||
| the <code>option</code>'s <span>shadow root</span> as the second child. It is | ||
| <span>expected</span> to take all child nodes of the <code>option</code> element. If the | ||
| <code>option</code> has the <code data-x="attr-option-label">label</code> attribute set to any | ||
| value besides the empty string, then the <span>option content slot</span> is | ||
| <span>expected</span> to have its <span>'display'</span> property set to 'none'.</p></li> | ||
| </ol> | ||
|
|
||
| <p>Each sequence of one or more child <code>hr</code> element siblings may be rendered as a single | ||
| separator.</p> | ||
|
|
@@ -148555,6 +148602,16 @@ select { | |
| block-size: calc(max(24px, 1lh) * attr(size type(<integer>), 4)); | ||
| }</code></pre> | ||
|
|
||
| <p>The following styles are <span>expected</span> to apply to the <span>optgroup label | ||
| element</span> when its parent <code>optgroup</code> element is being <span | ||
| data-x="optgroup-base-appearance">rendered with base appearance</span>:</p> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just make these unconditional based on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer not to, in chromium we have different styles for this element in appearance:auto: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/resources/html.css;l=2307-2309;drc=fc92cc6dc0a63cab87ad5e4ff9d3b17cdd7df198
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the shadow tree is conditional upon a select with base appearance so there is no optgroup label element without that. |
||
|
|
||
| <ul> | ||
| <li><p><code data-x="" class="css">padding-inline: 0.5em</code></p></li> | ||
|
|
||
| <li><p><code data-x="" class="css">min-block-size: 1lh</code></p></li> | ||
| </ul> | ||
|
|
||
| <div w-nodev> | ||
|
|
||
| <h4>The <code>textarea</code> element</h4> | ||
|
|
||
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.
Why are we talking about
optionelements here? Anoptgroupcan't haveoptionelement ancestors, can it? Can we reference the existing definition for nearest ancestor 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.
I did this in order to reuse the algorithm which determines when the elements inside a select besides the option are being rendered with base appearance: https://html.spec.whatwg.org/multipage/rendering.html#select's-options-are-being-rendered-with-base-appearance
I removed the word option from the algorithm to make that more clear. How does it look now?