Skip to content

Commit 6883525

Browse files
authored
fix: ignore relative selector lists when resolving multiple selectors (#921)
1 parent e22ecf1 commit 6883525

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/fela-plugin-multiple-selectors/src/__tests__/multipleSelectors-test.js

+16
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,20 @@ describe('multiple-selectors plugin', () => {
9999
},
100100
})
101101
})
102+
103+
it('should not resolve relative selector lists', () => {
104+
const style = {
105+
':not(:hover, :focus)': {
106+
color: 'blue',
107+
fontSize: 12,
108+
},
109+
}
110+
111+
expect(multipleSelectors()(style)).toEqual({
112+
':not(:hover, :focus)': {
113+
color: 'blue',
114+
fontSize: 12,
115+
},
116+
})
117+
})
102118
})

packages/fela-plugin-multiple-selectors/src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ function multipleSelectorsPlugin(style) {
66
if (isPlainObject(value)) {
77
const resolvedValue = multipleSelectorsPlugin(value)
88

9-
const selectors = property.split(',')
9+
// split on commas, but not within a relative selector list
10+
// e.g. ":hover, :focus", but not ":where(:hover, :focus)"
11+
const selectors = property.split(/(?<!\([^)]*),(?![^(]*\))/)
1012

1113
if (selectors.length > 1) {
1214
arrayEach(selectors, (selector) => {

0 commit comments

Comments
 (0)