Re: [WICG/webcomponents] Web components should be able to easily adapt to the host page while maintaining enapsulation (Issue #986)

I think ::part() is nice and works well, but for big / composed WCs it can be cumbersome to expose and document parts for every element inside a component.
So what if there would be something like a `::part-with-descendents` which would allow us to expose an element of the WC **including its children**.

For instance:
```html
<ul class="list" part-with-descendents="amazing-list">
    <li class="list__item">This in an item</li>
    <li class="list__item">This in another item <span class="list__banana">with something special</span></li>
</ul>
```

And then:
```css
cool-component::part(amazing-list) {
    border: 1px solid red;
}

cool-component::part(amazing-list .list__item) {
    color: tomato;
}

cool-component::part(amazing-list .list__banana) {
    text-transform: yellow;
}
```

This would allow the WC author to expose whole sections of the component, or maybe even the whole component if they want to.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/986#issuecomment-1897990784
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/986/1897990784@github.com>

Received on Thursday, 18 January 2024 08:10:54 UTC