webcomponents / webcomponents/polyfills
[ShadyCSS] Too specific slotted(*) causes unexpected styling
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
Here's an example of what I've found when styling in Polymer, although I assume the problem is with shady polyfill itself
I have a container element with a slot and default style for all slotted elements. It's important that I select the slotted element by id
``` html
section#sn :slotted(*) {
color: red;
}
```
In another element I distribute a node and apply same rule in Light DOM
``` html
p {
color: green;
}
Green text
```
**Expected behaviour**
The paragraph should be green
**Actual behaviour**
In browsers using polyfill it will be red.
Attached is the above example
[my-app.html.zip](https://github.com/webcomponents/shadycss/files/1640494/my-app.html.zip)
**Workaround**
When selecting the slotted element one has to be very careful not be too specific. Above even if changed to using class `section.slot ::slotted(*)` alone won't help without making the selector in `my-app` more specific like.
``` css
my-container p {
color: green;
}
```
Otherwise the naked `p` selector will still be too little specific.
Contributor guide
Assessment
This issue has not been assessed yet.