-
Notifications
You must be signed in to change notification settings - Fork 27
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
:host(:has(...)) pointing to light DOM content #208
Comments
+1! this would be amazing! imo one of the bad parts about slots is that it’s almost impossible to “enforce” what gets slotted into them. a lot of composable components depend on documentation and the components consumer to just do the right thing, but this could help us deal with more edge cases when an unexpected element gets slotted into a slot. |
@michaelwarren1106 I'd actually see #207 as being able to more fully enforce the contract that you're talking about there? |
Some discussions also in
@Westbrook did you open an issue in the CSS WG about this? It seems it would be a better avenue than here? no? |
@karlcow my understanding is that this IS spec, which is why Safari implemented it, but Chrome has lingering security questions, which is why their implementation is not interoperable with Safari’s. If FireFox implemented to spec, it would only be an Interop issue? |
Thank you for proposing We wanted to let you know that this proposal was not selected to be part of Interop this year. As discussed in the issue, there are tests for For an overview of our process, see the proposal selection summary. Thank you again for contributing to Interop 2023! Posted on behalf of the Interop team. |
Description
With a
:host()
selector referencing the root of an element with a shadow root, it holds that:host(:has(...)
should reference light DOM children of that root. Some browsers acknowledge this truth (Safari), others don't (Chrome), others have yet to ship:has()
support (Firefox).Example: https://codepen.io/Westbrook/pen/KKoJNGm
In Safari with
:has()
support you get:In Chrome with
:has()
support you get:Rationale
There's no way to "know" what content has been slotted into a shadow root carrying element without leveraging JS API. The combination of
:host()
and:has()
to form:host(:has())
means that advanced JS APIs are no longer required in order to style content (both in the shadow and light DOM).Specification
https://drafts.csswg.org/selectors-4/#relational
Tests
:has()
tests: https://wpt.fyi/results/css/selectors?label=master&label=experimental&aligned&view=subtest&q=has:host()
tests: https://wpt.fyi/results/css?label=master&label=experimental&aligned&view=subtest&q=hostI'm not sure (can't locate any) there are currently tests for this specific situation, but there should be!
The text was updated successfully, but these errors were encountered: