Skip to content

Commit 9e928ce

Browse files
Disable automatic var() injection for anchor properties (#13826)
* Disable automatic `var()` injection for CSS anchor positioning properties * Update tests * Update changelog
1 parent ff6f085 commit 9e928ce

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Disable automatic `var()` injection for anchor properties ([#13826](https://github.com/tailwindlabs/tailwindcss/pull/13826))
1113

1214
## [3.4.4] - 2024-06-05
1315

src/util/dataTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,24 @@ function isCSSFunction(value) {
1919
// More info:
2020
// - https://drafts.csswg.org/scroll-animations/#propdef-timeline-scope
2121
// - https://developer.mozilla.org/en-US/docs/Web/CSS/timeline-scope#dashed-ident
22+
// - https://www.w3.org/TR/css-anchor-position-1
2223
//
2324
const AUTO_VAR_INJECTION_EXCEPTIONS = new Set([
2425
// Concrete properties
2526
'scroll-timeline-name',
2627
'timeline-scope',
2728
'view-timeline-name',
2829
'font-palette',
30+
'anchor-name',
31+
'anchor-scope',
32+
'position-anchor',
33+
'position-try-options',
2934

3035
// Shorthand properties
3136
'scroll-timeline',
3237
'animation-timeline',
3338
'view-timeline',
39+
'position-try',
3440
])
3541

3642
// This is not a data type, but rather a function that can normalize the

tests/normalize-data-types.test.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,18 @@ it('should not automatically inject the `var()` for properties that accept `<das
112112
{ raw: '[color:--foo]' },
113113

114114
// Automatic var injection is skipped
115+
{ raw: '[scroll-timeline-name:--foo]' },
115116
{ raw: '[timeline-scope:--foo]' },
117+
{ raw: '[view-timeline-name:--foo]' },
118+
{ raw: '[font-palette:--foo]' },
119+
{ raw: '[anchor-name:--foo]' },
120+
{ raw: '[anchor-scope:--foo]' },
121+
{ raw: '[position-anchor:--foo]' },
122+
{ raw: '[position-try-options:--foo]' },
123+
{ raw: '[scroll-timeline:--foo]' },
124+
{ raw: '[animation-timeline:--foo]' },
125+
{ raw: '[view-timeline:--foo]' },
126+
{ raw: '[position-try:--foo]' },
116127
],
117128
}
118129

@@ -122,13 +133,45 @@ it('should not automatically inject the `var()` for properties that accept `<das
122133

123134
return run(input, config).then((result) => {
124135
expect(result.css).toMatchFormattedCss(css`
136+
.\[anchor-name\:--foo\] {
137+
anchor-name: --foo;
138+
}
139+
.\[anchor-scope\:--foo\] {
140+
anchor-scope: --foo;
141+
}
142+
.\[animation-timeline\:--foo\] {
143+
animation-timeline: --foo;
144+
}
125145
.\[color\:--foo\] {
126146
color: var(--foo);
127147
}
128-
148+
.\[font-palette\:--foo\] {
149+
font-palette: --foo;
150+
}
151+
.\[position-anchor\:--foo\] {
152+
position-anchor: --foo;
153+
}
154+
.\[position-try-options\:--foo\] {
155+
position-try-options: --foo;
156+
}
157+
.\[position-try\:--foo\] {
158+
position-try: --foo;
159+
}
160+
.\[scroll-timeline-name\:--foo\] {
161+
scroll-timeline-name: --foo;
162+
}
163+
.\[scroll-timeline\:--foo\] {
164+
scroll-timeline: --foo;
165+
}
129166
.\[timeline-scope\:--foo\] {
130167
timeline-scope: --foo;
131168
}
169+
.\[view-timeline-name\:--foo\] {
170+
view-timeline-name: --foo;
171+
}
172+
.\[view-timeline\:--foo\] {
173+
view-timeline: --foo;
174+
}
132175
`)
133176
})
134177
})

0 commit comments

Comments
 (0)