This commit is contained in:
Matt Van Horn 2026-09-26 08:50:30 -04:00 • committed by GitHub
commit da5b84a391
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 9 deletions

View file

@ -25752,6 +25752,38 @@ test('leading', async () => {
`)
})
test('leading-none is not shadowed by --spacing-none', async () => {
expect(
await compileCss(
css`
@theme {
--spacing-none: 0;
}
@tailwind utilities;
`,
['leading-none'],
),
).toMatchInlineSnapshot(`
"@layer properties {
@supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
*, :before, :after, ::backdrop {
--tw-leading: initial;
}
}
}
.leading-none {
--tw-leading: 1;
line-height: 1;
}
@property --tw-leading {
syntax: "*";
inherits: false
}"
`)
})
test('tracking', async () => {
expect(
await run(

View file

@ -416,10 +416,24 @@ export function createUtilities(theme: Theme) {
value = candidate.value.value
dataType = candidate.value.dataType
} else {
value = theme.resolve(
candidate.value.fraction ?? candidate.value.value,
desc.themeKeys ?? [],
)
let resolvedValue = candidate.value.fraction ?? candidate.value.value
// First try resolving against just the primary theme key.
value = theme.resolve(resolvedValue, desc.themeKeys?.slice(0, 1) ?? [])
// If the primary theme key didn't match, check static values before
// falling back to secondary theme keys (like `--spacing`). This
// ensures e.g. `leading-none` produces `line-height: 1` even when
// `--spacing-none` is defined in the theme.
if (value === null && !negative && desc.staticValues && !candidate.modifier) {
let fallback = desc.staticValues[candidate.value.value]
if (fallback) return fallback.map(cloneAstNode)
}
// Fall back to the full set of theme keys.
if (value === null) {
value = theme.resolve(resolvedValue, desc.themeKeys ?? [])
}
// If the theme value resolved without consuming the modifier, then
// the modifier would be silently ignored and `w-4` and `w-4/foo`
@ -448,11 +462,6 @@ export function createUtilities(theme: Theme) {
value = desc.handleBareValue(candidate.value)
if (!value?.includes('/') && candidate.modifier) return
}
if (value === null && !negative && desc.staticValues && !candidate.modifier) {
let fallback = desc.staticValues[candidate.value.value]
if (fallback) return fallback.map(cloneAstNode)
}
}
// If there is no value, don't generate any rules.