Skip to content

Commit

Permalink
fix(core): don't treat arrow functions as variant groups (#1922)
Browse files Browse the repository at this point in the history
  • Loading branch information
sibbng committed Nov 29, 2022
1 parent d2c9c5a commit 01df814
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/utils/variantGroup.ts
@@ -1,6 +1,6 @@
import type MagicString from 'magic-string'

export const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm
export const regexClassGroup = /((?:[!\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])+?)\)(?!\s*?=>)/gm

export function expandVariantGroup(str: string, seperators?: string[], depth?: number): string
export function expandVariantGroup(str: MagicString, seperators?: string[], depth?: number): MagicString
Expand Down
26 changes: 26 additions & 0 deletions test/transformer-variant-group.test.ts
Expand Up @@ -58,4 +58,30 @@ describe('transformer-variant-group', () => {
"
`)
})

test('empty group', async () => {
const result = await transform(
'hover:()',
)
expect(result).toMatchInlineSnapshot('"hover:()"')
})

test('ignore arrow fn', async () => {
const result = await transform(`
{
hover:(p6) => {
console.log('ok')
},
}
`)
expect(result).toMatchInlineSnapshot(`
"
{
hover:(p6) => {
console.log('ok')
},
}
"
`)
})
})

0 comments on commit 01df814

Please sign in to comment.