Skip to content

Commit

Permalink
fix(core): support expand @ for variant group (#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Dec 21, 2022
1 parent e21c581 commit 4d951a1
Show file tree
Hide file tree
Showing 2 changed files with 6 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:/\\,%#.$-]|\[.*?\])+?)\)(?!\s*?=>)/gm
export const regexClassGroup = /((?:[!@\w+:_/-]|\[&?>?:?.*\])+?)([:-])\(((?:[~!\w\s:/\\,%#.$-]|\[.*?\])+?)\)(?!\s*?=>)/gm

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

test('expand @', async () => {
expect(expandVariantGroup('@a:(c-d d-c)')).toEqual('@a:c-d @a:d-c')
expect(expandVariantGroup('!@a:(c-d d-c)')).toEqual('!@a:c-d !@a:d-c')
})
})

0 comments on commit 4d951a1

Please sign in to comment.