mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2026-10-28 17:56:21 +08:00
## Summary
`unescape` treats every two-character match as a simple character
escape, including a backslash followed by a single hexadecimal digit.
For example, `\a` becomes the letter `a` instead of U+000A, and `\0`
becomes `0` instead of U+FFFD.
Distinguish hexadecimal escapes from simple escapes using separate
capture groups. This preserves the existing handling of one-to-six hex
digits, optional trailing whitespace, and invalid code points.
This also fixes theme variable normalization: `@theme { --color-\0: red;
}` currently registers `--color-0`, while the CSS reference
`var(--color-\0)` refers to a different identifier. Add a compilation
regression test alongside the helper tests.
Reference: [CSS Syntax — consume an escaped code
point](https://www.w3.org/TR/css-syntax-3/#consume-escaped-code-point).
## Test plan
- With the original implementation, the nine new single-digit helper
cases and the new compilation case fail.
- `pnpm exec vitest run --project tailwindcss
packages/tailwindcss/src/utils/escape.test.ts` — 19 passed.
- `pnpm exec vitest run --project tailwindcss
packages/tailwindcss/src/index.test.ts -t 'single-digit hexadecimal'` —
1 passed.
- Prettier check on all three changed files — passed.
- `pnpm exec vitest run --project tailwindcss` — 5,158 passed, 3 failed,
1 skipped. The same three snapshot failures were verified on unmodified
upstream `f7f47f8`: CSS mixins, rounded utilities, and theme string
indexing.
- Full Rust/build verification has not been run; the partial workspace
typecheck limitation noted during setup remains.