cssinjs / cssinjs/jss

Wrong CSS specificity

Open
#1,045 6 comments 2 reactions 1 assignee Claimed by @kof View on GitHub
bug complexity:moderate help wanted
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

Take the following style as an input:
```js
const style = {
root: {
"&:hover": {
"& .icon": {
color: "red"
}
},
"&.active": {
"& .icon": {
color: "blue"
}
}
},
};
```

__Expected behavior:__
I would expect the following CSS injected into the page:
```css
.root-0-0-1:hover .icon {
color: red;
}
.root-0-0-1.active .icon {
color: blue;
}
```

__Describe the bug:__
The following CSS is injected in the page:
```css
.root-0-0-1.active .icon {
color: blue;
}
.root-0-0-1:hover .icon {
color: red;
}
```

__Codesandbox link:__

https://codesandbox.io/s/yjyqmo4vqv

__Versions (please complete the following information):__
- jss: 10.0.0-alpha.11

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.