Mixing style objects and functions messes up specificity resolution
- Dominant language
- JavaScript
- Stars
- 214
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
Expected:
```tsx
const Title = styled("h1")(p => ({
background: "blue"
}));
const Title2 = styled(Title)({
background: "green"
});
```
Expected:
Title2 is green
Resulted:
Title2 is blue, because it has 2 class names and one of them loses the specificity war.
Repro:
https://codesandbox.io/s/styled-jss-playground-repro-mo3c8
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked CodeSandbox reproduction and compare the generated styles for Title and Title2. Trace how styled components combine function-based and object-based styles and how their class names affect specificity. Done means Title2 renders with a green background instead of blue, with the reproduction behavior covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100