diff --git a/CHANGELOG.md b/CHANGELOG.md index 2740ac27b481..4243ca1ec616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure files with only `@theme` produce no output when built ([#18979](https://github.com/tailwindlabs/tailwindcss/pull/18979)) - Support Maud templates when extracting classes ([#18988](https://github.com/tailwindlabs/tailwindcss/pull/18988)) - Show version mismatch (if any) when running upgrade tool ([#19028](https://github.com/tailwindlabs/tailwindcss/pull/19028)) +- Upgrade: Ensure first class inside className in React is migrated ([#19031](https://github.com/tailwindlabs/tailwindcss/pull/19031)) +- Upgrade: Migrate classes inside `*ClassName` and `*Class` attributes ([#19031](https://github.com/tailwindlabs/tailwindcss/pull/19031)) ## [4.1.13] - 2025-09-03 diff --git a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts index 8bcaf52f427a..2061f27d4ad2 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.test.ts @@ -112,4 +112,27 @@ describe('is-safe-migration', async () => { }), ).toEqual(candidate) }) + + test.each([ + // Vue classes + [`
`, 'shadow', 'shadow-sm'], + [``, 'shadow', 'shadow-sm'], + [``, 'shadow', 'shadow-sm'], + [``, 'shadow', 'shadow-sm'], + + // React classes + [``, 'shadow', 'shadow-sm'], + [``, 'shadow', 'shadow-sm'], + + // Preact-style + [``, 'shadow', 'shadow-sm'], + ])('replaces classes in valid positions #%#', async (example, candidate, expected) => { + expect( + await migrateCandidate(designSystem, {}, candidate, { + contents: example, + start: example.indexOf(candidate), + end: example.indexOf(candidate) + candidate.length, + }), + ).toEqual(expected) + }) }) diff --git a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts index 7851db65002e..fa7ee7f4a1c5 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts @@ -5,18 +5,16 @@ import * as version from '../../utils/version' const LOGICAL_OPERATORS = ['&&', '||', '?', '===', '==', '!=', '!==', '>', '>=', '<', '<='] const CONDITIONAL_TEMPLATE_SYNTAX = [ - // Vue - /v-else-if=['"]$/, - /v-if=['"]$/, - /v-show=['"]$/, - /(?