-
Notifications
You must be signed in to change notification settings - Fork 671
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
[css-pseudo][css-shadow-parts] Define "part-like pseudo-element" concept #10083
Comments
Note that a downside of "you can access it in two different ways" is that we need to define and implement cascading the two things together. (I don't think defining it is hard since I don't think they differ in context, and I think any specificity differences are well defined. Implementing it might be trickier.) |
Yes, same context, so that's not an issue. Cascading (ideally?) shouldn't be any more difficult than what's already possible, since you have to cascade, say, |
There was also a topic in the conversation about ensuring that existing pseudo-elements should be marked as part-like, when they represent something that's basically (or actually) a real element under the covers. Here's the full list of pseudo-elements that are currently defined, according to Bikeshed, and categorized according to my initial impressions: Clearly should work
Probably should work
Probably irrelevant and shouldn't work?
Maybe should work?
Clearly should not work
|
Pinging @rniwa in particular for the above list, since they brought up this aspect in the call. |
Re I'm not clear on some of the points you mentioned that part-like pseudos would provide, but if they give an ability for shadow DOM to export them and be styled by the host, then it may be relevant to the discussion. And most of those elements do have boxes and possibly act like images |
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.
Part of the needed spec changes here have landed. One part that I think has not landed yet is a definition that says that part-like pseudo-elements have the same rules as It's also possible that those rules should move to selectors rather than css-shadow-parts; that might also help with #10787. |
I think there's also an open question about how to extend the rule that |
Actually, I think that suggestion was more complex than needed. I think since pseudo-elements are built-in, and we aren't planning to expose parts on built-in things, there isn't any need for |
Yeah, just disallowing ::part() after a part-like is fine; part-likes are equivalent to ::part() and similarly don't want to expose further internal structure. |
(And just to be clear, the inverse is not true; part-likes other than ::part() should be allowed after part-likes. That's already required for compat, since you can access various pseudo-elements on a ::part, and it's the right move anyway imo. This does require that we stick to our guns that built-in parts are always exposed as bespoke part-like pseudos, or at least are exposed as both bespoke pseudos and ::part() names.) |
The CSS Working Group just discussed The full IRC log of that discussion<dholbert> dbaron: this one, we already had a resolution, but I wanted to give a brief update since the state of things is confusing<dholbert> dbaron: so we resolved to make this :part-like pseudo-element concept <dholbert> dbaron: half of the edits are edited in, but not all of them <dholbert> fantasai: e.g. this edit, which has been waiting for this current discussion <fantasai> -> https://github.com//pull/10839/files <dholbert> dbaron: we've made some of the edits, to make partlikes like ::part <dholbert> dbaron: earlier we were discussing what selectors and pseudo-classes apply after ::part <dholbert> dbaron: those all apply to ::part-like as well, and I'm planning to make those edits <dholbert> dbaron: Tab made edits about what properties apply. But the selector edits have not yet been made <dholbert> dbaron: that's all |
This has been renamed to |
In the WHATNOT joint session with CSSWG today, we resolved that the new
details
pseudos would indeed be exposed as normal UA pseudo-elements (rather than::part()
s), but that we'd define a new concept of "part-like pseudo-elements" that grants the pseudo the abilities of ::part() that we want to preserve.Namely:
exportparts
attribute will gain a syntax for exporting part-like pseudos, details TBDIIRC, the only real point of contention left is that, for normal parts, you only have access to the parts declared or exported by the component itself. If you expose a sub-component as a part, you do not get access to its parts too (that is, you can't ever write
my-el::part(my-foo)::part(their-bar)
), specifically so we don't expose the fact that the part is implemented as a nested component rather than plain DOM. But parts do provide access to their pseudo-elements (you can writemy-el::part(my-foo)::before
), because that's useful and many pseudo-elements aren't remotely appropriate to be exported as parts themselves.But these two points are now in conflict. If you can export a part-like pseudo to be one of your component's parts, but you can also access it as a pseudo-element, it means you can spell the same selector two distinct ways:
my-el::part(my-content)
andmy-el::part(my-details)::details-content
.This does expose the fact that a part is a particular built-in element, but that's a fact we already explicitly exposed, so it's not a new information leak. (Any element-specific pseudo-classes also expose this.)
It also means there's two ways to refer to the same element, but that's generally true of selectors, so I don't find this a particularly compelling problem.
I suggest, then, that we simply accept this as a possibility. But we could try to work around it in a few ways:
my-el::part(file)::file-selector-button
, and it requires people to be very aware of the part-like pseudos exposed by any particular element.my-el::part(my-details)::details-contents
ormy-el::part(my-contents)
for a given element, but never both. This potentially allows for inconsistent behavior, where some pseudos are allowed (because they weren't exported under another name) but others aren't.I think all three of these have downsides, and personally consider them to outweigh the downside of just "you can access it in two different ways". So I recommend not doing anything special for this.
The text was updated successfully, but these errors were encountered: