Skip to content

Conversation

@govizlora
Copy link
Contributor

Summary

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

<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

/(?<!:?class)=['"]$/

to

/(?<!:?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

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

@govizlora govizlora requested a review from a team as a code owner September 29, 2025 22:45
@govizlora govizlora changed the title Fix react classnames not being migrated Sep 29, 2025
This lets things like `enterClass` and `enterClassName` work which are common React-isms
@thecrypticace thecrypticace changed the title Fix first react classname not being migrated Sep 30, 2025
@thecrypticace thecrypticace enabled auto-merge (squash) September 30, 2025 15:10
@thecrypticace thecrypticace merged commit 47d6a02 into tailwindlabs:main Sep 30, 2025
7 checks passed
@thecrypticace
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants