tailwindcss/packages
govizlora 47d6a023e3
Ensure first class inside className in React is migrated (#19031)
### 1. Handling React className migration

The PR fixes an issue when migrating React components to tailwind v4
with the migration tool, that the first class after `className="` is
ignored.

For example, when migrating
```JSX
<div className="shadow"></div>
```
`shadow` will not be migrated to `shadow-sm` .

This is because in `is-safe-migration.ts`, it tests the line before
candidate with regex `/(?<!:?class)=['"]$/`. This basically skips the
migration for anything like `foo="shadow"`, with only exception for Vue
(eg. `class="shadow"`).

The PR changes the regex from

```regex
/(?<!:?class)=['"]$/
````
to
```regex
/(?<!:?class|className)=['"]$/
```
which essentially adds a new exception specifically for React's
`className="shadow"` case.

### 2. Removing redundant rules

Besides, I found that several other rules in
`CONDITIONAL_TEMPLATE_SYNTAX` being redundant since they are already
covered by the rule above, so I removed them. If we prefer the previous
explicit approach, I can revert it.

## Test plan

<!--

Explain how you tested your changes. Include the exact commands that you
used to verify the change works and include screenshots/screen
recordings of the update behavior in the browser if applicable.

-->

Tests added for both the Vue and React classes to prevent false negative
cases.

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2025-09-30 11:13:14 -04:00
..
@tailwindcss-browser Prepare v4.1.13 release (#18868) 2025-09-04 13:18:25 -04:00
@tailwindcss-cli Fix CLI watcher cleanup race (#18905) 2025-09-09 17:14:09 +02:00
@tailwindcss-node Update jiti 2.5.1 → 2.6.0 (minor) (#19029) 2025-09-29 09:51:45 -04:00
@tailwindcss-postcss Add Upgrading from Tailwind CSS v… when running upgrade tool (#19026) 2025-09-29 15:59:54 +02:00
@tailwindcss-standalone Update bun 1.2.20 → 1.2.22 (patch) (#19007) 2025-09-29 09:16:06 +00:00
@tailwindcss-upgrade Ensure first class inside className in React is migrated (#19031) 2025-09-30 11:13:14 -04:00
@tailwindcss-vite Use default export condition for @tailwindcss/vite (#18948) 2025-09-16 15:04:13 -04:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Update magic-string to version 0.30.19 2025-09-26 19:12:26 +00:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00