@@ -154,33 +154,31 @@ describe('preset-wind4', () => {
154154 ] ,
155155 theme : {
156156 colors : {
157- foo : 'var(--colors-bar)' ,
158- bar : 'var(--colors-baz-bcd, #000)' ,
159- baz : {
160- bcd : 'var(--colors-test, #fff)' ,
161- } ,
162- test : '#fff' ,
157+ // foo: 'var(--colors-bar)',
158+ // bar: 'var(--colors-baz-bcd, #000)',
159+ // baz: {
160+ // bcd: 'var(--colors-test, #fff)',
161+ // },
162+ // ^^^ don't do this
163+
164+ // issue #4994: Chaining CSS variables within a theme is strongly discouraged,
165+ // as it can cause browsers to fail to resolve variables to the correct values promptly during evaluation (or recalculation).
166+ // Furthermore, Uno does not perform in-depth analysis of the source of these references.
167+ primary : `var(--custom-css-variable, #123456)` ,
168+ secondary : `calc(var(--another-css-variable, 10%) + 5%)` ,
163169 } ,
164170 } ,
165171 } )
166172
167- const { css } = await uno . generate ( 'c-foo ' )
173+ const { css } = await uno . generate ( 'c-primary c-primary/50 c-secondary ' )
168174 expect ( css ) . toMatchInlineSnapshot ( `
169175 "/* layer: properties */
170176 @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{--un-text-opacity:100%;}}
171177 @property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%;}
172- /* layer: theme */
173- :root, :host {
174- --colors-foo: var(--colors-bar);
175- --colors-bar: var(--colors-baz-bcd, #000);
176- --colors-baz-bcd: var(--colors-test, #fff);
177- --colors-test: #fff;
178- }
179178 /* layer: default */
180- .c-foo{color:color-mix(in srgb, var(--colors-foo) var(--un-text-opacity), transparent) /* var(--colors-bar) */;}
181- @supports (color: color-mix(in lab, red, red)){
182- .c-foo{color:color-mix(in oklab, var(--colors-foo) var(--un-text-opacity), transparent) /* var(--colors-bar) */;}
183- }"
179+ .c-primary{color:color-mix(in srgb, var(--custom-css-variable, #123456) var(--un-text-opacity), transparent) /* var(--custom-css-variable, #123456) */;}
180+ .c-primary\\/50{color:color-mix(in srgb, var(--custom-css-variable, #123456) 50%, transparent) /* var(--custom-css-variable, #123456) */;}
181+ .c-secondary{color:color-mix(in srgb, calc(var(--another-css-variable, 10%) + 5%) var(--un-text-opacity), transparent) /* calc(var(--another-css-variable, 10%) + 5%) */;}"
184182 ` )
185183 } )
186184
0 commit comments