Repository navigation
Fix mask axis conflicts and arbitrary stop positions - #748
Conversation
Moves the descriptions of `isArbitraryMaskPosition` and `isArbitraryVariableMaskPosition` into the arbitrary value and arbitrary variable validator tables, so they follow the same structure as the other validators instead of trailing paragraphs. Drops the mask examples from the features page. Mask axis conflicts and stop positions are too specific to feature there, so the docs example count goes back to its previous value.
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
β¦idators
The mask position validator had its own copy of the color function regex because the shared `colorFunctionRegex` missed Tailwind's `--alpha()` and only matched lowercase function names. Both gaps also affected the length validator: `twMerge('text-[--alpha(red/50%)] text-lg')` and `twMerge('text-[RGB(0_0_0/50%)] text-lg')` read the color as a font size and dropped it, because the percentage inside matched as a length.
Adds `--alpha` and case-insensitive matching to `colorFunctionRegex` and lets the mask validator reuse it, so there is a single list to extend when new color functions come up. Adds regression tests for `--alpha()` and uppercase color functions next to the other color-function tests, and notes the shared list in the agent docs.
The note said later edge classes "remain refinements" of an earlier `mask-x-*` or `mask-y-*` class. That only holds for stop positions. For stop colors, Tailwind emits the axis rule after the edge rule, the same way it does for `border-x-*` and `border-r-*` colors, so the axis color applies regardless of class order. Keeping both classes is still the right merge result, but the note should not suggest the edge color wins.
dcastil
left a comment
There was a problem hiding this comment.
Thanks for your PR! Looks good, I only added some minor tweaks.
|
This was addressed in release tailwind-merge@3.7.0-dev.b6569fd8bc74a4cdcf92989bc942c24de38ba2a8. |
|
This was addressed in release tailwind-merge@3.7.1. |
Mask axis utilities now remove earlier matching edge utilities while preserving independent colors and positions. For example,
twMerge('mask-r-to-red-500 mask-x-to-blue-500')returnsmask-x-to-blue-500; reversing the order preserves both classes so the right edge can refine the axis.Adds eight directional conflict rules for the x/y axes and mask-specific arbitrary-position validators. The validators are necessary because values such as
[20px]and(--position)previously fell into color groups, so the new axis conflicts would otherwise remove independent edge colors. Lengths, numbers, angles, and non-color functions remain positions; named colors, hex colors, color functions, andcolor:variables remain separate.Includes regression coverage for both edges, reverse ordering, independent stops/values, arbitrary values/variables, variants, and important modifiers. Updates API and behavior documentation and the configurator's 13 emitted-module snapshots.
Fixes #746, #747.
Validation:
pnpm lintpnpm test:typespnpm testβ 658 tests passed across 79 files, including Vite and Next.js integration testspnpm --filter tailwind-merge buildpnpm --filter tailwind-merge test:exportsβ CJS, ESM, ES5, and TypeScript 3.8 declaration compatibility