-
Notifications
You must be signed in to change notification settings - Fork 693
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
::details-content
vs details::part(content)
#9951
Comments
I think the only reason If the syntax for |
I like that built-in pseudo-elements have a distinct syntax from non-built-in ones do, it makes it easy to distinguish what the browser provides by default from what the browser doesn't. |
Citation needed?:::part() and the part attribute allows multiple identifiers, not sure how that could be achieved with a syntax like that. Part is strictly more powerful than regular pseudo elements.
Sure, but for each we need to define what pseudo classes if any are valid to the right of the pseudo. Also what properties apply to it. All these are answered for for part. I don't see part as a built in pseudo element, it can expose multiple elements and elements can have multiple parts, it's a more powerful feature. The fact that WebKit uses that mechanism to implement some pseudos is kind of an implementation detail. |
I think that'd be super weird, to target something sometimes as part and sometimes as pseudo-element. Also we probably don't want to do this for all pseudo elements, it's unclear what exposing a first-line should do, for example? I think that's not great alternative, and if we go for a pseudo element we should just tell people to export the whole details element for such use case (which might not be what they want, necessarily, but would allow you to do ::part(details)::details-content the same way you can do ::part(input)::placeholder nowadays. |
Previous discussions on this topic:
Note that a big chunk of the Open UI discussion was the week after the Cupertino F2F discussion, and the combination of those two made me give up on trying to push for |
I don't think we should be using I'm immensely annoyed that this topic is getting re-litigated again. |
There are many things we could say about what an individual participant in a discussion thought the motivations for something were at the time. For example, I could point out the post I over wrote 21 years ago describing one of the core motivations for wanting XBL (early in a decade-long standards journey that eventually led to web components) as being able to describe builtin controls and allow them to be styled. But I don't think either of those opinions represent clearly documented consensus, and even if they did, new evidence can lead reopening of issues where there was previous consensus. |
I consider Rationale:
|
It's a namespace for the creator of the shadow, which can be the author or the UA. It's different to
But the spec mandates a shadow tree, and this is already exposed to authors. E.g. if they use |
I think discussion |
I'm not sure I agree, it is confusing the first time because it's new, but long term it's IMO less confusing, specially for developers already familiar with parts.
Sure, though same thing, that's a one-time issue. That's also fixable (e.g., you can expose
I'm not sure I get this argument. We already define An aside / another topic worth looking into, is that there's another difference between Pseudo-elements always inherit from its originating element, while input { color: red }
input::slider-track { color: green }
input::slider-thumb { background-color: currentColor; } /* red! */ Alternatively, we might want to have a weird "part-like pseudo-element" that behaves like this... But that's a new CSS concept. I think that if we're going to define new controls in terms of shadow trees, using The big drawback that I see with |
No, that was one reason. The other reason was to allow the class-like semantics, where an element can be exposed and/or targeted via multiple part names. (As the co-author of the spec, I can speak definitively on this.)
It was to namespace, yes, but the conclusion you're subsequently drawing from that (that the UA should never be allowed to use ::part()) is incorrect. The ::part() namespace of a component is owned by the owner of the component's shadow DOM. Arbitrary authors cannot interfere with a given component's names (unlike many other namespaces we explicitly carved out for authors, like custom properties). So, since the
This isn't particularly appropriate to express in this venue.
I sympathize with "confusing", but this is still a meaningfully distinct situation from
This is the big argument against ::part(), I think.
I'm not sure what "open/closed" has relevance here, but yes, it does expose the fact that the element has a shadow tree (or at least masquerades as having one). This is already supported in the spec in any case - authors aren't allowed to install a shadow tree of their own on
Well right now the choice is "target it as a pseudo-element" (if you have access to the originating element) or "you can't target it at all, sucks to be you" ^_^. I think allowing the second situation to become "target as a part" is an improvement; it allows people to, say, wrap a
Right, it would need to be tree-abiding pseudos only. Non-tree-abiding are virtually always an exception.
Yeah, it's possible, but awkward. ^_^ It forces the author to expose the fact that something is implemented as a |
I think there is a plan to discuss this at the WHATNOT meeting tomorrow; see whatwg/html#10200 . (This meeting is exactly 24 hours after the CSS call.) |
Ok, so things that I want discussed after chatting with @smaug---- (putting here for reference and so I don't forget):
|
I think we should also discuss:
|
I will find out how to link to the minutes of the joint meeting we just had with WHATNOT, but the conclusion was: Proposed resolution: We will use pseudo-elements for exposing styling of pieces of built-in controls. We would like these pseudo-elements to be as close to ::part() as possible (for example, in terms of what selectors work and how inheritance works) and intend to further explore the details of how to do this. With this proposed resolution passing a meeting poll |
The joint discussion we had concluded with the following resolution: RESOLUTION: We will use pseudo-elements for exposing styling of pieces of built-in controls. We would like these pseudo-elements to be as close to ::part() as possible (for example, in terms of what selectors work and how inheritance works) and intend to further explore the details of how to do this. (somebody else may have a "more official" copy of this, not sure) My intent with this resolution is that we'd be able to move towards defining a concept of "part-like pseudo-element" so that we can share definitions between the places in specs that define such pseudo-elements. There are a few other things that we discussed that require some further exploration:
A few other notes from the discussion were that:
but the consensus of the discussion moved away from doing either of these. |
Raised the "part-like pseudo-element" issue in #10083 |
Slightly more detail in meeting notes here: whatwg/html#10200 (comment) |
This makes a number of related changes to specify the rendering of the <details> element: * It specifies the structure of the user agent shadow tree. This appears largely interoperable between implementations with the exception of the style or link element for the default summary styles: Gecko uses a link element as the first child, Chromium uses a style element as the last child, and WebKit does not use a style element (see below). This specifies a style or link as the first child. * It specifies the existence of the default summary and the presence of UA dependent text inside of it. This is present in all of Chromium, Gecko, and WebKit. * It specifies the styles needed for the default summary. These match Chromium and Gecko. (These are not present in WebKit because WebKit's mechanism for styling the marker does not match the existing spec.) * It removes the restriction that <details> is a block and cannot be changed. This is prototyped in Chromium and Gecko. This fixes whatwg#9830. * It specifies that the summary element is display: block by default. This matches all of Chromium, Gecko, and WebKit. * It specifies which element matches the ::details-content pseudo-element. (TODO: This needs to be specified in CSS) This is prototyped in Chromium. See w3c/csswg-drafts#9879 and w3c/csswg-drafts#9951 for more background.
Every use case I’ve seen where multiple part names are used, only one is actually a true part name, and the others are states which are better addressed as custom pseudo-classes. |
I'm rather curious as to why there is no As a CSS author, API consistency is important, so I support |
This adds the ::details-content pseudo-element as resolved in: 1. w3c#9879 (comment) 2. whatwg/html#10200 (comment) / w3c#9951 (comment) 3. w3c#9879 (comment) and uses the definition added in w3c#10083.
This adds the ::details-content pseudo-element as resolved in: 1. w3c#9879 (comment) 2. whatwg/html#10200 (comment) / w3c#9951 (comment) 3. w3c#9879 (comment) and uses the definition added in w3c#10083.
This adds the ::details-content pseudo-element as resolved in: 1. #9879 (comment) 2. whatwg/html#10200 (comment) / #9951 (comment) 3. #9879 (comment) and uses the definition added in #10083.
@dbaron From my testing, Chrome(128.0.6544.0) doesn't currently support |
Yes. |
This makes a number of related changes to specify the rendering of the <details> element: * It specifies the structure of the user agent shadow tree. This appears largely interoperable between implementations with the exception of the style or link element for the default summary styles: Gecko uses a link element as the first child, Chromium uses a style element as the last child, and WebKit does not use a style element (see below). This specifies a style or link as the last child with a note that the order is not observable. * It specifies the existence of the default summary and the presence of UA dependent text inside of it. This is present in all of Chromium, Gecko, and WebKit. * It specifies the styles needed for the default summary. These match Chromium and Gecko. (These are not present in WebKit because WebKit's mechanism for styling the marker does not match the existing spec; see [bug 157323](https://bugs.webkit.org/show_bug.cgi?id=157323).) * It removes the restriction that <details> is a block and cannot be changed. This is prototyped in Chromium and Gecko. This fixes #9830. * It specifies that the summary element is display: block by default. This matches all of Chromium, Gecko, and WebKit. * It specifies which element matches the ::details-content pseudo-element. This is prototyped in Chromium. * It makes a potentially riskier change by making the <slot> element that matches ::details-content be display: block all the time (rather than only when closed). This is prototyped in Chromium (more recently than the other changes). See w3c/csswg-drafts#9879 and w3c/csswg-drafts#9951 for more background.
@LeaVerou an example where I have used multiple parts - I have a calendar component with lots of |
At the F2F, there was some discussion about how to expose the
<slot>
in the<details>
element's shadow DOM that wraps the details' content.There are two main options: a new pseudo-element (provisionally called
::details-content
), or a shadow part (provisionally called::part(content)
).Arguments for
::details-content
:input::file-selector-button
Arguments for
::part(content)
::part(content):hover
works by defaultDuring the meeting, we seemed to recall that this topic had been previously brought up, and both WebKit engineers and the HTML spec editors disliked it. Our recollection of their reasoning was:
I think that (1) is reasonable, tho that's historical precedent from before
::part()
even existed. It might be reasonable to change that. For example, we could make all those element-specific pseudo-elements also exposed as::part()
, as that would give you the "export this as one of the wrapping component's parts" ability that I allude to above.But I will push back on (2) very strongly. It is important to not impinge on author-controlled namespaces; you don't want to accidentally clash with existing author-defined names, and it's not great to have certain special names be illegal for authors to use.
But neither of those apply here. The owner of a given element's ::part() namespace is the owner of that component's shadow DOM. I designed this very carefully to make sure that's 100% true - the owner of a component's shadow can choose to import the names from a sub-component for themselves, but it's always an extremely explicit choice. You'll never get surprised by names showing up in your namespace you don't expect.
So, here, the UA is the owner of the
details
shadow. If it wants to expose a part name, nothing any author can do will ever interact negatively with that.¹: That is, if you have a custom component
<my-widget>
that contains a<details>
element in its shadow, you could use<details exportparts=content>
, and thenmy-widget::part(content)
works, targeting the details-content box. This is impossible to do with a pseudo-element, at least right now.Tho we could attack this from the other direction - rather than turn all existing element-specific pseudo-elements into ::part()s so they can be used in
exportparts
, we could just allow pseudo-elements to be used inexportparts
, like<details exportparts="::details-content : content">
./cc @emilio
The text was updated successfully, but these errors were encountered: