diff --git a/src/util/formatVariantSelector.js b/src/util/formatVariantSelector.js index 38a8bfbc7..ee6350b8e 100644 --- a/src/util/formatVariantSelector.js +++ b/src/util/formatVariantSelector.js @@ -218,7 +218,7 @@ export function finalizeSelector(current, formats, { context, candidate, base }) parent.insertAfter(simpleSelector[simpleSelector.length - 1], simpleEnd) for (let child of formatNodes) { - parent.insertBefore(simpleSelector[0], child) + parent.insertBefore(simpleSelector[0], child.clone()) } node.remove() diff --git a/tests/basic-usage.test.js b/tests/basic-usage.test.js index f71dc9106..b8849fe83 100644 --- a/tests/basic-usage.test.js +++ b/tests/basic-usage.test.js @@ -922,4 +922,31 @@ crosscheck(({ stable, oxide }) => { `) }) }) + + it('should not crash when matching variants where utility classes are doubled up', () => { + let config = { + content: [ + { + raw: '
', + }, + ], + } + + let input = css` + @tailwind utilities; + @layer utilities { + .foo.foo { + text-decoration-line: underline; + } + } + ` + + return run(input, config).then((result) => { + expect(result.css).toMatchFormattedCss(css` + .hover\:foo:hover.hover\:foo:hover { + text-decoration-line: underline; + } + `) + }) + }) })