Repository navigation
fix: recognize contrast-color and device-cmyk as colors - #729
Merged
Merged
Conversation
Contributor
Author
Exclude both functions from arbitrary length detection so percentages do not remove unrelated font sizes, border widths, or stroke widths. Add regression coverage for both class orders and document the behavior. Signed-off-by: Don Yin <Don_Yin@outlook.com>
β¦res page The tests in `colors.test.ts` and `validators.test.ts` already cover both functions, and the features page doesn't need an example for every color function, so the two examples and the matching docs example count go back to what main has. Since the rebase, mask stops share `colorFunctionRegex` as well, so `contrast-color()` and `device-cmyk()` now count as colors there too. Tailwind puts them into the mask position variable instead, which only produces a broken gradient, so the agent notes record this as an accepted difference rather than keeping a mask-specific color list.
dcastil
force-pushed
the
fix/contrast-color-device-cmyk
branch
from
November 17, 2026 23:00
773dcb1 to
70b0e09
Compare
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
|
This was addressed in release tailwind-merge@3.7.0-dev.61f8790d2e377c5013a4e23947d2aeaedd7adbd5. |
|
This was addressed in release tailwind-merge@3.7.1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I noticed that percentages inside
contrast-color()anddevice-cmyk()are treated as lengths. This can remove an unrelated font-size class:This adds both functions to the existing color-function exclusion in the length validator. The tests cover font-size, border-width, stroke-width, and text-color replacement in both orders, with two checked documentation examples. Tailwind CSS 4.3.3 generates separate
font-sizeandcolordeclarations for the reproduction.Evidence
The same eight merge cases per function fail before the change and pass afterward. The figure shows case counts, not a performance benchmark.
Measured inputs and outputs: before, after.
Validation
pnpm --filter tailwind-merge test tests/colors.test.ts tests/validators.test.ts tests/docs-examples.test.ts. 31 passed. Before the fix, the color and validator files had 3 failed / 27 passed tests.pnpm test. 648 passed across 78 files, including the Vite and Next.js integration tests.pnpm lintpnpm test:typespnpm --filter tailwind-merge buildpnpm --filter tailwind-merge test:exportspnpm exec prettier --checkon the five changed files.All commands passed. The full test run reported the existing locked-version mismatch between Vitest 4.1.11 and its coverage provider 4.1.10; no dependencies were changed.