Skip to content

Commit

Permalink
fix: move pseudo elements with parentheses (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
sibbng committed Jul 29, 2022
1 parent d290c84 commit 38c0875
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/generator/index.ts
Expand Up @@ -642,7 +642,7 @@ function applyScope(css: string, scope?: string) {
}

export function movePseudoElementsEnd(selector: string) {
const pseudoElements = selector.match(/::[\w-]+/g)
const pseudoElements = selector.match(/::[\w-]+(\([\w-]+\))?/g)
if (pseudoElements) {
pseudoElements.forEach(e => (selector = selector.replace(e, '')))
selector += pseudoElements.join('')
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/order.test.ts.snap
Expand Up @@ -10,7 +10,7 @@ exports[`order > fully controlled rules merged and sorted by body 1`] = `
.css{--var:css;}"
`;

exports[`order > movePseudoElementsEnd 1`] = `".marker\\\\:file\\\\:hover\\\\:selection\\\\:mb-4:hover::marker::file-selector-button::selection"`;
exports[`order > movePseudoElementsEnd 1`] = `".part-\\\\[hello-2\\\\]\\\\:marker\\\\:file\\\\:hover\\\\:selection\\\\:mb-4:hover::part(hello-2)::marker::file-selector-button::selection"`;

exports[`order > multiple variant sorting 1`] = `
"/* layer: default */
Expand Down
2 changes: 1 addition & 1 deletion test/order.test.ts
Expand Up @@ -110,7 +110,7 @@ describe('order', () => {
})

test('movePseudoElementsEnd', () => {
expect(movePseudoElementsEnd('.marker\\:file\\:hover\\:selection\\:mb-4::marker::file-selector-button:hover::selection'))
expect(movePseudoElementsEnd('.part-\\[hello-2\\]\\:marker\\:file\\:hover\\:selection\\:mb-4::part(hello-2)::marker::file-selector-button:hover::selection'))
.toMatchSnapshot()
})

Expand Down

0 comments on commit 38c0875

Please sign in to comment.