Skip to content

Commit

Permalink
fix(variant-group): filter spaces, close #828
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 20, 2022
1 parent 671e30b commit f660cfa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/core/src/utils/variantGroup.ts
Expand Up @@ -17,6 +17,7 @@ export function expandVariantGroup(str: string | MagicString, seperators: ('-' |
return from
return body
.split(/\s/g)
.filter(Boolean)
.map(i => i === '~' ? pre : i.replace(/^(!?)(.*)/, `$1${pre}${sep}$2`))
.join(' ')
},
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/transformer-variant-group.test.ts.snap
Expand Up @@ -11,7 +11,7 @@ exports[`transformer-variant-group > basic > "dark:lg:(p-1 p-2)" 1`] = `"dark:lg
exports[`transformer-variant-group > basic > "hover:(
!m-2
p-2
)" 1`] = `"hover: !hover:m-2 hover: hover:p-2 hover:"`;
)" 1`] = `"!hover:m-2 hover:p-2"`;

exports[`transformer-variant-group > basic > "hover:(!m-2 p-2)" 1`] = `"!hover:m-2 hover:p-2"`;

Expand Down
4 changes: 4 additions & 0 deletions test/variant-group.test.ts
Expand Up @@ -24,4 +24,8 @@ describe('variant-group', () => {
test('nested', () => {
expect(expandVariantGroup('a-(b c-(d e f))')).toEqual('a-b a-c-d a-c-e a-c-f')
})

test('spaces', () => {
expect(expandVariantGroup('a-( ~ b c )')).toEqual('a a-b a-c')
})
})

0 comments on commit f660cfa

Please sign in to comment.