Re: [WICG/webcomponents] CSS selector to style slots with slotted elements (#936)

So, so much this! At Adobe we currently leverage a mixin for this https://github.com/adobe/spectrum-web-components/blob/main/packages/shared/src/observe-slot-presence.ts and the related has assigned text functionality https://github.com/adobe/spectrum-web-components/blob/main/packages/shared/src/observe-slot-text.ts having this functionality by default without keeping track of slot changes would be amazing. 

It’s too bad there was initial pushback on `:has` as I think that would be an amazing approach `:host(:has(::slotted(input)))` seems so right for the customization of an input leveraging [Decorator Pattern Plus](https://dev.to/westbrook/testing-accessibility-with-shadow-roots-55cm#the-decorator-pattern-plus) or similar and needing to decide whether you’ve received an input or created one.

In the bike shed, I’d love for this to better match the JS API of `slot.assignedElements` and `el.assignedNodes` and see something like `slot:hasAssignedElements(button, a)` or `slot:assignedNodes` as the selectors here so that you could be specific in both directions. 

Would be very excited to bring to the [Web Components Community Group](https://github.com/w3c/webcomponents-cg) for further feedback!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/936#issuecomment-1085446110

You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/936/1085446110@github.com>

Received on Friday, 1 April 2022 05:40:50 UTC