Skip to content

Commit

Permalink
Handle variants when the same class appears multiple times in a selec…
Browse files Browse the repository at this point in the history
…tor (#10397)
  • Loading branch information
thecrypticace authored Jan 23, 2023
1 parent 937ac13 commit 667eac5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/formatVariantSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 27 additions & 0 deletions tests/basic-usage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
`)
})
})
})

0 comments on commit 667eac5

Please sign in to comment.