Skip to content

Commit 78fac38

Browse files
authored
fix(styled): fix nested states (#221)
1 parent a340b33 commit 78fac38

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/core/src/transform.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const props = {
77
},
88
}
99

10-
const transformToStr = (s) =>
10+
const transformToStr = (s: string) =>
1111
transform(s)
12-
.map((x) => (typeof x === 'function' ? x(props) : x))
12+
.map((x: Function | string) => (typeof x === 'function' ? x(props) : x))
1313
.join('')
1414

1515
describe('#transform', () => {
@@ -71,4 +71,10 @@ describe('#transform', () => {
7171
'div{color:#000;}@media(min-width:1920px){div{color:#000;}}div{color:#000;}',
7272
)
7373
})
74+
75+
it('handles nested states', () => {
76+
expect(transformToStr('&:hover:not(:active) { color: black; }')).toBe(
77+
'&:hover:not(:active) { color: #000; }',
78+
)
79+
})
7480
})

packages/core/src/transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { propGetters } from './propGetters'
55
// prop name is an ident: word chars, underscore and dash.
66
const PROP_CHAR = `[-\\w]`
77

8-
// prop value consists of non-semis unless backslash-escaped.
9-
const VALUE_CHAR = `(?:\\\\.|[^\\\\;])`
8+
// prop value consists of non-semis and no curly braces unless backslash-escaped.
9+
const VALUE_CHAR = `(?:\\\\.|[^\\\\;{}])`
1010

1111
// prettier-ignore
1212
const PROP_PATT = (

0 commit comments

Comments
 (0)