From 25f272a693e9d2893f7fe5f1b436dfcfb1e5d274 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 13 Oct 2025 09:21:12 -0400 Subject: [PATCH 1/2] Clone AST nodes in `staticValues` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These were getting mutated but they were shared instead of being re-created for new candidates. Cloning the nodes fixes this so mutation of the AST nodes doesn’t stick around. --- packages/tailwindcss/src/index.test.ts | 44 ++++++++++++++++++++++++++ packages/tailwindcss/src/utilities.ts | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/tailwindcss/src/index.test.ts b/packages/tailwindcss/src/index.test.ts index ce8b7f6013c9..f1dad6ccda4e 100644 --- a/packages/tailwindcss/src/index.test.ts +++ b/packages/tailwindcss/src/index.test.ts @@ -537,6 +537,50 @@ describe('@apply', () => { `) }) + it('@apply does not cache important state', async () => { + expect( + await compileCss(css` + .c1 { + @apply leading-none; + } + .c2 { + @apply leading-none!; + } + .c3 { + @apply 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; + } + } + } + + .c1 { + --tw-leading: 1; + line-height: 1; + } + + .c2 { + --tw-leading: 1 !important; + line-height: 1 !important; + } + + .c3 { + --tw-leading: 1; + line-height: 1; + } + + @property --tw-leading { + syntax: "*"; + inherits: false + }" + `) + }) + it('should error when using @apply with a utility that does not exist', async () => { await expect( compile(css` diff --git a/packages/tailwindcss/src/utilities.ts b/packages/tailwindcss/src/utilities.ts index 0ef9907bb31c..c0c0bd7daf17 100644 --- a/packages/tailwindcss/src/utilities.ts +++ b/packages/tailwindcss/src/utilities.ts @@ -436,7 +436,7 @@ export function createUtilities(theme: Theme) { if (value === null && !negative && desc.staticValues && !candidate.modifier) { let fallback = desc.staticValues[candidate.value.value] - if (fallback) return fallback + if (fallback) return fallback.map(cloneAstNode) } } From 1994503e70f460b2a1da1240eeee3ed2849773d5 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 13 Oct 2025 09:23:19 -0400 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69359fb1c2e9..375d5079e27e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Suppress Lightning CSS warnings about `:deep`, `:slotted`, and `:global` ([#19094](https://github.com/tailwindlabs/tailwindcss/pull/19094)) - Fix resolving theme keys when starting with the name of another theme key in JS configs and plugins ([#19097](https://github.com/tailwindlabs/tailwindcss/pull/19097)) - Allow named groups in combination with `not-*`, `has-*`, and `in-*` ([#19100](https://github.com/tailwindlabs/tailwindcss/pull/19100)) +- Prevent important utilities from affecting other utilities ([#19110](https://github.com/tailwindlabs/tailwindcss/pull/19110)) - Upgrade: Canonicalize utilities containing `0` values ([#19095](https://github.com/tailwindlabs/tailwindcss/pull/19095)) ## [4.1.14] - 2025-10-01