-
Notifications
You must be signed in to change notification settings - Fork 375
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
Support for pseudo elements with ::slotted() selectors #655
Comments
Thanks for register! I would like use it. |
The pseudo-elements aren't slotted, so (2) is out. (3) works for me from a spec perspective, and seems useful for authors; there's no good reason behaviorally to disallow it, I think? Only question is if it's reasonable engine-wise. |
The last time we discussed this, the question was what would happen if the slotted element had already specified |
I think cascading order or specificity of these selectors are already clear in the current spec. |
Generated content like |
Yeah, there's no reason to be different there. |
Regarding engines, implementing this in Blink is just a matter of allowing it in the selector parser. Adding a simple check made ::before/::after/::first-line/::first-letter seemingly work out-of-the-box. |
An admissive Blink implementation with tests: https://chromium-review.googlesource.com/c/616042 |
Thanks @rune-opera! 👏 |
So, the proposal is to resolve as option (3). Allow pseudo element after ::slotted() like: ::slotted(*)::before. Should this be scheduled for resolution at a csswg telcon? |
And done; the tree-abiding pseudos (::before, ::after, ::marker, and ::placeholder) can all go after ::slotted() now. |
@rune-opera @tabatkins and the selectors like
|
@abdonrd Yes. |
Thanks! :) |
Thanks @robdodson for filled at Webkit! https://bugs.webkit.org/show_bug.cgi?id=178237 |
Does <dom-module id="my-element">
<template>
<style>
slot[name="a"]::slotted(div:first-child) {
background-color: red;
}
</style>
<slot></slot>
<slot name="a"></slot>
</template>
</dom-module id="my-element">
<my-element>
<div>Bar</div>
<div slot="a">Foo</div>
<div slot="a">Bar</div>
</my-element> Is "Foo" supposed to have a red background? In latest Chrome, it doesn't. |
@hayatoito Do I understand correctly that this has been only implemented in Blink for The following CSS doesn't work in Chrome, Safari and Firefox: ::slotted(input)::placeholder {
color: red;
} Live example: https://jsfiddle.net/webpadawan/v3ksqhcx/ |
@web-padawan |
Works in Firefox Nightly FWIW, and I think @lilles fixed it on Blink too. |
Fixed: https://crbug.com/902518 |
Would be grate to use this kind of selectors:
|
@BinaryCry feature requests are best done in a new issue, though please take https://whatwg.org/faq#adding-new-features into account. Thanks! |
Anyone else observing that Safari and Chrome on iOS are not working with this ? |
WebKit bug tracks the issue on iOS. |
::slotted & :hosthttps://developer.mozilla.org/en-US/docs/Web/CSS/::slotted https://developer.mozilla.org/en-US/docs/Web/CSS/:host https://developers.google.com/web/fundamentals/web-components/shadowdom
/* Selects any element placed inside a slot */
::slotted(*) {
font-weight: bold;
}
/* Selects any <span> placed inside a slot */
::slotted(span) {
font-weight: bold;
} /* Selects a shadow root host */
:host {
font-weight: bold;
} |
Here is another WebKit bug for |
This was discussed in Issue #331 but I don't think we came to a conclusion.
The CSS Scoping spec does not explicitly disallow pseudo elements in the "selector list" like the specs for :not() and :matches() do. Neither does it currently explicitly allow pseudo elements after ::slotted.
Should we:
@hayatoito @tabatkins
The text was updated successfully, but these errors were encountered: