nested css selector element& broken in emotion 11
See original GitHub issueI’m upgrading from emotion 10 to 11 and experiencing some changes in how my “button” selector works which I apply to button and a elements.
.button {
color: blue
&:hover, &:focus, &.is-active {
&:enabled, a& {
color: red
}
}
}
This previously generated the following correct css
/* for :enabled <button> elements */
.button:hover:enabled,
.button:focus:enabled,
.button.is-active:enabled,
/* <a> elements styled as buttons */
a.button:hover,
a.button:focus,
a.button.is-active {
color: red
}
as shown and isolated in https://codesandbox.io/s/modest-lederberg-db4bt?file=/src/App.js
After upgrading to emotion 11 the following css is generated which breaks it.
.button:hover:enabled,
.button:focus:enabled,
.button:hover a&,
.button:focus a&{
background:blue
}
To reproduce:
See the sandbox which isolates the issue. https://codesandbox.io/s/relaxed-shamir-yleem?file=/src/App.js Its the same as above, I just swapped out the dependencies.
Expected behavior:
Generated CSS should be the same as previously in emotion 10.
react
version: 17.0.2 (also seen with 16.14)@emotion/react
version: 11.4.1
As also the stylis version changed I already raised an issue over there at https://github.com/thysultan/stylis.js/issues/274
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Nested selectors behaviour #235 - emotion-js/emotion - GitHub
This smells funky, and it creates a semantic rift between what it means to nest selectors and what it means to nest elements....
Read more >Nested Selectors - Emotion
Sometimes it's useful to nest selectors to target elements inside the current class or React component. An example with an element selector is...
Read more >React Emotion Styled Component: Class selector not working
I have built a switch the same way and using a class selector I can change the CSS of another component when the...
Read more >Why We're Breaking Up with CSS-in-JS - DEV Community
My SASS components are usually flat and I only nest when doing something like the lobotomized owl. For getting colors or dimensions from...
Read more >Selectors - W3C
In CSS, pattern matching rules determine which style rules apply to elements in the document tree. These patterns, called selectors, may range from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not yet - being busy at the moment, hope to get back to this later this week but no promises.
@Andarist Wow, thank you so much for looking into this and your hard work ❤️