-
Notifications
You must be signed in to change notification settings - Fork 378
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
Styling default slot content with ::slotted #631
Comments
This indeed seems counterintuitive. This might be just implementation bugs in both WebKit and Blink given the spec text. |
Good catch. Yeah, I think this is not a spec bug. This should be considered as an implementation bug. The following is a brief history:
Regarding the spec, although we have not considered anything about an impact for If it is okay, I'll file a bug in Blink and close this spec bug. |
I've filed a bug for Blink: https://bugs.chromium.org/p/chromium/issues/detail?id=703984 |
Filed a WebKit bug in https://bugs.webkit.org/show_bug.cgi?id=169948 as well. |
Thanks! |
While this has been closed for some time, I’m currently have this same issue, and I have been getting directed here from search. I did not see any resolution from the browser vendors, so if it helps others in a similar predicament, I am using the following workaround: :not([name])::slotted(*) {} |
I've come across a case where a component wants to style default
slot
content with::slotted
, but cannot do so.For reference, default slot content are direct
slot
children, which are used if no light DOM nodes are assigned to the shadow host:Such default nodes are returned in calls to
assignedNodes({ flatten: true })
. (They are not returned in calls toassignedNodes()
, which seems weird to me, but that's a separate point.)The puzzle is why the
div
above can't be styled with the::slotted
selector. This use case is important for a component that wants to provide consistent styling for both default slot content and explicitly assigned nodes.See http://jsbin.com/cuvetul/edit?html,output for a demo whose behavior is consistent in both Blink and WebKit, and yet counter to what I would expect. My reasoning:
assignedNodes({ flatten: true })
on a slot with no explicitly assigned nodes returns the default slot content. This is consistent with the above point.::slotted
styles all flattened nodes assigned to a slot, which is consistent with the above point, but not the slot's default nodes, which is surprising.(Disclaimer: I've done my best to locate what I believe are the most current specs, and interpret them to the best of my ability. That said, web specs usually melt my small brain. People with bigger brains may be able to interpret the above specs differently.)
I'm hitting this issue in a real-world Shadow DOM component that wants to apply consistent styling to a slot's assigned nodes in all cases.
If there's agreement that
::slotted
should apply to all of a slot's flattened assigned nodes, so that::slotted
andassignedNodes({ flatten: true })
can gain the close correspondence implied by the specs, then I'd be happy to file bugs against WebKit and Blink.The text was updated successfully, but these errors were encountered: