Skip to content

Commit 67d8b18

Browse files
committed
keep whitespace when merging @utility nodes
1 parent 8cb6a1d commit 67d8b18

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

integrations/cli/upgrade.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ test(
116116
&::-webkit-scrollbar {
117117
display: none;
118118
}
119+
119120
-ms-overflow-style: none;
120121
scrollbar-width: none
121122
}

packages/@tailwindcss-upgrade/src/codemods/migrate-at-layer-utilities.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ it('should merge `@utility` definitions with the same name', async () => {
399399
).toMatchInlineSnapshot(`
400400
"@utility step {
401401
counter-increment: step;
402+
402403
&:before {
403404
@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;
404405
@apply ml-[-41px];
@@ -477,6 +478,7 @@ it('should migrate advanced combinations', async () => {
477478
}
478479
}
479480
}
481+
480482
@media (width >= 200px) {
481483
&:hover {
482484
@apply bg-red-500;
@@ -495,6 +497,7 @@ it('should migrate advanced combinations', async () => {
495497
}
496498
}
497499
}
500+
498501
@media (width >= 100px) {
499502
color: red;
500503
}

packages/@tailwindcss-upgrade/src/codemods/migrate-at-layer-utilities.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ export function migrateAtLayerUtilities(): Plugin {
222222
root.walkAtRules('utility', (node) => {
223223
let existing = nameToAtRule.get(node.params)
224224
if (existing) {
225-
node.each((child) => {
226-
existing.append(child)
227-
})
225+
// Add a newline between each `@utility` at-rule
226+
if (node.first) {
227+
node.first.raws.before = `\n${node.first?.raws.before ?? ''}`
228+
}
229+
existing.append(node.nodes ?? [])
228230
node.remove()
229231
} else {
230232
nameToAtRule.set(node.params, node)

0 commit comments

Comments
 (0)