Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- _Experimental_: Fix incorrect empty `layer()` at the end of `@import` at-rules when running codemods ([#14513](https://github.com/tailwindlabs/tailwindcss/pull/14513))
- _Experimental_: Migrate `@import "tailwindcss/tailwind.css"` to `@import "tailwindcss"` ([#14514](https://github.com/tailwindlabs/tailwindcss/pull/14514))
- _Experimental_: Do not wrap comment nodes in `@layer` when running codemods ([#14517](https://github.com/tailwindlabs/tailwindcss/pull/14517))
- _Experimental_: Ensure we don't lose selectors when running codemods ([#14518](https://github.com/tailwindlabs/tailwindcss/pull/14518))

## [4.0.0-alpha.25] - 2024-09-24

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,3 +783,40 @@ describe('comments', () => {
`)
})
})

// Saw this when testing codemods on https://github.com/docker/docs
it('should not lose attribute selectors', async () => {
expect(
await migrate(css`
@layer components {
#TableOfContents {
.toc a {
@apply block max-w-full truncate py-1 pl-2 hover:font-medium hover:no-underline;
&[aria-current='true'],
&:hover {
@apply border-l-2 border-l-gray-light bg-gradient-to-r from-gray-light-100 font-medium text-black dark:border-l-gray-dark dark:from-gray-dark-200 dark:text-white;
}
&:not([aria-current='true']) {
@apply text-gray-light-600 hover:text-black dark:text-gray-dark-700 dark:hover:text-white;
}
}
}
}
`),
).toMatchInlineSnapshot(`
"@layer components {
#TableOfContents {
.toc a {
@apply block max-w-full truncate py-1 pl-2 hover:font-medium hover:no-underline;
&[aria-current='true'],
&:hover {
@apply border-l-2 border-l-gray-light bg-gradient-to-r from-gray-light-100 font-medium text-black dark:border-l-gray-dark dark:from-gray-dark-200 dark:text-white;
}
&:not([aria-current='true']) {
@apply text-gray-light-600 hover:text-black dark:text-gray-dark-700 dark:hover:text-white;
}
}
}
}"
`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export function migrateAtLayerUtilities(): Plugin {
return WalkAction.Stop
}
})
node.selector = selector.toString()
})
}).processSync(node.selector, { updateSelector: false })
}).processSync(node, { updateSelector: true })
})

// Upgrade every Rule in `@layer utilities` to an `@utility` at-rule.
Expand Down Expand Up @@ -157,10 +156,7 @@ export function migrateAtLayerUtilities(): Plugin {
}
})
})

// Update the selector
node.selector = selectors.toString()
}).processSync(node.selector)
}).processSync(node, { updateSelector: true })

// Cleanup all the nodes that should not be part of the `@utility` rule.
if (!containsClass) {
Expand Down