File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/tailwindcss-language-service/src/util/rewriting Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,25 @@ import { resolveVariableValue } from './lookup'
3
3
import { replaceCssVars } from './replacements'
4
4
5
5
export function replaceCssVarsWithFallbacks ( state : State , str : string ) : string {
6
+ let seen = new Set < string > ( )
7
+
6
8
return replaceCssVars ( str , {
7
9
replace ( { name, fallback } ) {
8
10
// Replace with the value from the design system first. The design system
9
11
// take precedences over other sources as that emulates the behavior of a
10
12
// browser where the fallback is only used if the variable is defined.
11
13
if ( state . designSystem && name . startsWith ( '--' ) ) {
14
+ // TODO: This isn't quite right as we might skip expanding a variable
15
+ // that should be expanded
16
+ if ( seen . has ( name ) ) return null
12
17
let value = resolveVariableValue ( state . designSystem , name )
13
- if ( value !== null ) return value
18
+ if ( value !== null ) {
19
+ if ( value . includes ( 'var(' ) ) {
20
+ seen . add ( name )
21
+ }
22
+
23
+ return value
24
+ }
14
25
}
15
26
16
27
if ( fallback ) {
You can’t perform that action at this time.
0 commit comments