@@ -377,12 +377,13 @@ impl StyleSheet {
377377 st. style_order ( ) ,
378378 if !single_css { Some ( filename) } else { None } ,
379379 )
380- } else if let Some ( StyleProperty :: ClassName ( cls) ) =
381- style. extract ( if !single_css { Some ( filename) } else { None } )
382- {
383- cls
384380 } else {
385- continue ;
381+ match st. extract ( if !single_css { Some ( filename) } else { None } ) {
382+ StyleProperty :: ClassName ( cls)
383+ | StyleProperty :: Variable {
384+ class_name : cls, ..
385+ } => cls,
386+ }
386387 } ;
387388
388389 if self . add_property_with_layer (
@@ -2360,4 +2361,56 @@ mod tests {
23602361 assert ! ( css. contains( "width:1px" ) ) ;
23612362 assert ! ( !css. contains( "width:2px" ) ) ;
23622363 }
2364+
2365+ #[ test]
2366+ #[ serial]
2367+ fn test_first_value_without_dollar_prefix_uses_raw_value ( ) {
2368+ reset_class_map ( ) ;
2369+ reset_file_map ( ) ;
2370+ let mut sheet = StyleSheet :: default ( ) ;
2371+
2372+ let mut styles = FxHashSet :: default ( ) ;
2373+ // FirstValue resolution but value has no $ prefix — should use the raw value as-is
2374+ styles. insert ( ExtractStyleValue :: Static (
2375+ ExtractStaticStyle :: new ( "width" , "100px" , 0 , None )
2376+ . with_theme_token_resolution ( ThemeTokenResolution :: FirstValue ) ,
2377+ ) ) ;
2378+
2379+ let ( collected, _) = sheet. update_styles ( & styles, "test.tsx" , true ) ;
2380+ assert ! ( collected) ;
2381+
2382+ let css = sheet. create_css ( None , false ) ;
2383+ assert ! ( css. contains( "width:100px" ) ) ;
2384+ }
2385+
2386+ #[ test]
2387+ #[ serial]
2388+ fn test_first_value_box_shadow_resolves_shadow_token ( ) {
2389+ reset_class_map ( ) ;
2390+ reset_file_map ( ) ;
2391+ let mut sheet = StyleSheet :: default ( ) ;
2392+ let theme: Theme = serde_json:: from_str (
2393+ r#"{
2394+ "shadow": {
2395+ "default": {
2396+ "card": ["0 1px 2px #0003", null, "0 4px 8px #0003"]
2397+ }
2398+ }
2399+ }"# ,
2400+ )
2401+ . unwrap ( ) ;
2402+ sheet. set_theme ( theme) ;
2403+
2404+ let mut styles = FxHashSet :: default ( ) ;
2405+ styles. insert ( ExtractStyleValue :: Static (
2406+ ExtractStaticStyle :: new ( "box-shadow" , "$card" , 0 , None )
2407+ . with_theme_token_resolution ( ThemeTokenResolution :: FirstValue ) ,
2408+ ) ) ;
2409+
2410+ let ( collected, _) = sheet. update_styles ( & styles, "test.tsx" , true ) ;
2411+ assert ! ( collected) ;
2412+
2413+ let css = sheet. create_css ( None , false ) ;
2414+ assert ! ( css. contains( "box-shadow:0 1px 2px #0003" ) ) ;
2415+ }
23632416}
0 commit comments