Open keithamus opened 8 months ago
So I tend to think we shouldn't allow these because they expose the language / direction of ancestors / descendants of the part, which feels a bit weird.
But that said I know the rules about :lang()
/ :dir()
in shadow trees have been discussed quite a bit... cc @meyerweb @zcorpan @rniwa
@tabatkins recently edited the parsing tests to assert that those are valid: https://github.com/web-platform-tests/wpt/pull/43796 . It does indeed seem to be what the spec says, I'm happy to settle with that.
I guess the question is "do we consider :dir()
and :lang()
to "reveal tree structure"? I think you could say they do... If so, they should never match, probably.
Given https://github.com/whatwg/html/pull/9880#issuecomment-1892568094 I'd much rather make them invalid for now and make a decision once all those HTML issues about how language and directionality work in the shadow DOM are settled.
I don't mind either way tbh. One question if we do reject them is whether they should be unparsable altogether or just match nothing.
Unparsable works with supports and such, so that seems preferable.
The CSS Working Group just discussed [css-shadow-parts] Should `::part():lang()` and `::part():dir()` be valid?
, and agreed to the following:
RESOLVED: :lang()/:dir() do apply to ::part
Context
When implementing CSS CustomStateSet (
:state(x)
) one of the test cases became using it after::part(x)
which seems very reasonable; there are many existing states which are allowable on::part(x)
such as:focus
,:hover
and so on so it stands to reason that custom states should also be allowed.:state(x)
highlighted something tricky though, because Stylo's parser special cases functional pseudo selectors, of which there are:dir()
,:lang()
, and now:state()
. Stylo explicitly flags:part()
so it can disallow:lang/:dir
(see this code whereafter_part
is checked). WebKit, on the other hand, does not discriminate functional pseudo selectors from their non-functional counterparts, and so::part(x):lang(y)
works and also handles all the proper invalidation. Chrome does not successfully parse these selectors either, but I can't speak for how Chrome's parser works in this regard, perhaps @josepharhar can.When speaking with @emilio about this, I was encouraged to file this very spec issue (better late than never :wink:).
Given Safari already parses and properly invalidates
:lang
/:dir
on::part()
, I thought I'd add some WPTs (parsing, invalidation of::part():lang()
, invalidation of::part():dir()
, cc @nt1m). We can clearly see Safari is the outlier in this regard, as Chrome nor Firefox parse the selectors.Problem statement
The question becomes: should Safari disallow
:lang()
/:dir()
after part? Or should Firefox & Chrome allow it?