Skip to content

Commit

Permalink
fix(core): update variant group regex (#1426)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Aug 17, 2022
1 parent 9ff2f7f commit 5a21fb3
Show file tree
Hide file tree
Showing 2 changed files with 5 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:/\\,%#.$-]|\[.*?\])*?)\)/gm

export function expandVariantGroup(str: string, seperators?: ('-' | ':')[]): string
export function expandVariantGroup(str: MagicString, seperators?: ('-' | ':')[]): MagicString
Expand Down
4 changes: 4 additions & 0 deletions test/variant-group.test.ts
Expand Up @@ -32,4 +32,8 @@ describe('variant-group', () => {
test('square bracket', async () => {
expect(expandVariantGroup('b:[&:not(c)]:d:(!a z)')).toEqual('!b:[&:not(c)]:d:a b:[&:not(c)]:d:z')
})

test('square bracket case2', async () => {
expect(expandVariantGroup('[&]:(a-b c-d)')).toEqual('[&]:a-b [&]:c-d')
})
})

0 comments on commit 5a21fb3

Please sign in to comment.