Skip to content

Commit

Permalink
fix: ignore relative selector lists when resolving multiple selectors (
Browse files Browse the repository at this point in the history
  • Loading branch information
1000hz authored Nov 6, 2024
1 parent e22ecf1 commit 6883525
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,20 @@ describe('multiple-selectors plugin', () => {
},
})
})

it('should not resolve relative selector lists', () => {
const style = {
':not(:hover, :focus)': {
color: 'blue',
fontSize: 12,
},
}

expect(multipleSelectors()(style)).toEqual({
':not(:hover, :focus)': {
color: 'blue',
fontSize: 12,
},
})
})
})
4 changes: 3 additions & 1 deletion packages/fela-plugin-multiple-selectors/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function multipleSelectorsPlugin(style) {
if (isPlainObject(value)) {
const resolvedValue = multipleSelectorsPlugin(value)

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

if (selectors.length > 1) {
arrayEach(selectors, (selector) => {
Expand Down

0 comments on commit 6883525

Please sign in to comment.