Skip to content

Commit

Permalink
keep whitespace when merging @utility nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Sep 20, 2024
1 parent c0fdbed commit 747b376
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions integrations/cli/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ test(
&::-webkit-scrollbar {
display: none;
}
-ms-overflow-style: none;
scrollbar-width: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ it('should merge `@utility` definitions with the same name', async () => {
).toMatchInlineSnapshot(`
"@utility step {
counter-increment: step;
&:before {
@apply absolute w-7 h-7 bg-default-100 rounded-full font-medium text-center text-base inline-flex items-center justify-center -indent-px;
@apply ml-[-41px];
Expand Down Expand Up @@ -477,6 +478,7 @@ it('should migrate advanced combinations', async () => {
}
}
}
@media (width >= 200px) {
&:hover {
@apply bg-red-500;
Expand All @@ -495,6 +497,7 @@ it('should migrate advanced combinations', async () => {
}
}
}
@media (width >= 100px) {
color: red;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,11 @@ export function migrateAtLayerUtilities(): Plugin {
root.walkAtRules('utility', (node) => {
let existing = nameToAtRule.get(node.params)
if (existing) {
node.each((child) => {
existing.append(child)
})
// Add a newline between each `@utility` at-rule
if (node.first) {
node.first.raws.before = `\n${node.first?.raws.before ?? ''}`
}
existing.append(node.nodes ?? [])
node.remove()
} else {
nameToAtRule.set(node.params, node)
Expand Down

0 comments on commit 747b376

Please sign in to comment.