Handle variants when the same class appears multiple times in a selector (#10397)

This commit is contained in:
Jordan Pittman 2023-01-23 08:13:59 -05:00 • committed by GitHub
parent 937ac139a1
commit 667eac5e88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View file

@ -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()

View file

@ -922,4 +922,31 @@ crosscheck(({ stable, oxide }) => {
`)
})
})
it('should not crash when matching variants where utility classes are doubled up', () => {
let config = {
content: [
{
raw: '<div class="hover:foo"></div>',
},
],
}
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;
}
`)
})
})
})