Re: [csswg-drafts] [css-shadow-parts] Unifying ::part() and ::--foo (#4900)

> (Alternately, maybe what's needed there is parts with states. Then, in that example, day would be a part, but weekend, week-1, us-holiday and saturday would be states? Seems kind of right for us-holiday but kind of wrong for saturday.)

Right. ^_^ There's the issue of forcing the author to make a fairly arbitrary choice between a particular name being "tagname-like" or "class-like" for a given part, which I don't think is *usually* a very meaningful distinction.

There's also the issue of syntax - if "states" here are expressed as custom pseudo-classes, then we run into the syntax collision I outline in <https://github.com/w3c/csswg-drafts/issues/4900#issuecomment-604107827>, where two non-cooperating parties (the outer component author and the inner component author) are both trying to expose custom pseudo-classes on the same element.

And if they're *not* expressed as custom pseudo-classes, then how? Either we scope the names into a pseudo-class function, so you have `::--day:state(weekend)` in which case you've reinvented `::part()` but more verbosely ^_^, or we open up syntax a bit more and allow something like `::--day.weekend`, so that the state-like part names are just classes.

I might be okay with that last option, btw! It still has the "tagname vs class" artificial distinction that I don't like, but I could live with it if others are happier.

(Alternately, we just use `::part`, no parens, to name all the parts, and all the part names are classes, like `::part.day.weekend`. I'd be happier with this variant.)

> Side note: is it useful to do what ::part(foo bar:baz) does for custom parts for built-in pseudo-elements? I could totally imagine a native date picking exposing parts similar to what you had for your custom calendar, but it would apparently have no way to solve the same problem. If so, perhaps what's really missing is a generic CSS syntax for pseudo-element multi matching?

Yes, it probably would be useful. And luckily, if we go with option 3 from my original post (author-defined part names must start with `--`), then we could just reuse the same syntax! UA-defined parts would just be non-dashed, like `input[type=date]::part(day weekend)`.

(...I guess that means `::part(before)` would be another way to spell `::before`? I'd be okay with that, I think.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4900#issuecomment-625566216 using your GitHub account

Received on Friday, 8 May 2020 00:36:36 UTC