Skip to content

Commit 2cba831

Browse files
Clone AST nodes used in staticValues (#19110)
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. Fixes #19108
1 parent 249bed0 commit 2cba831

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Suppress Lightning CSS warnings about `:deep`, `:slotted`, and `:global` ([#19094](https://github.com/tailwindlabs/tailwindcss/pull/19094))
1818
- 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))
1919
- Allow named groups in combination with `not-*`, `has-*`, and `in-*` ([#19100](https://github.com/tailwindlabs/tailwindcss/pull/19100))
20+
- Prevent important utilities from affecting other utilities ([#19110](https://github.com/tailwindlabs/tailwindcss/pull/19110))
2021
- Upgrade: Canonicalize utilities containing `0` values ([#19095](https://github.com/tailwindlabs/tailwindcss/pull/19095))
2122

2223
## [4.1.14] - 2025-10-01

packages/tailwindcss/src/index.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,50 @@ describe('@apply', () => {
537537
`)
538538
})
539539

540+
it('@apply does not cache important state', async () => {
541+
expect(
542+
await compileCss(css`
543+
.c1 {
544+
@apply leading-none;
545+
}
546+
.c2 {
547+
@apply leading-none!;
548+
}
549+
.c3 {
550+
@apply leading-none;
551+
}
552+
`),
553+
).toMatchInlineSnapshot(`
554+
"@layer properties {
555+
@supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {
556+
*, :before, :after, ::backdrop {
557+
--tw-leading: initial;
558+
}
559+
}
560+
}
561+
562+
.c1 {
563+
--tw-leading: 1;
564+
line-height: 1;
565+
}
566+
567+
.c2 {
568+
--tw-leading: 1 !important;
569+
line-height: 1 !important;
570+
}
571+
572+
.c3 {
573+
--tw-leading: 1;
574+
line-height: 1;
575+
}
576+
577+
@property --tw-leading {
578+
syntax: "*";
579+
inherits: false
580+
}"
581+
`)
582+
})
583+
540584
it('should error when using @apply with a utility that does not exist', async () => {
541585
await expect(
542586
compile(css`

packages/tailwindcss/src/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export function createUtilities(theme: Theme) {
436436

437437
if (value === null && !negative && desc.staticValues && !candidate.modifier) {
438438
let fallback = desc.staticValues[candidate.value.value]
439-
if (fallback) return fallback
439+
if (fallback) return fallback.map(cloneAstNode)
440440
}
441441
}
442442

0 commit comments

Comments
 (0)