@@ -12079,17 +12079,67 @@ impl<'a> VisitMut for TransformVisitor<'a> {
1207912079 }
1208012080
1208112081 fn visit_mut_jsx_element ( & mut self , element : & mut JSXElement ) {
12082+ if std:: env:: var_os ( "COMPILED_DEBUG_CSS" ) . is_some ( ) {
12083+ let element_name = match & element. opening . name {
12084+ JSXElementName :: Ident ( ident) => ident. sym . as_ref ( ) . to_string ( ) ,
12085+ _ => "<complex>" . to_string ( ) ,
12086+ } ;
12087+ eprintln ! ( "[compiled-debug] visit_mut_jsx_element <{}>" , element_name) ;
12088+ }
12089+
12090+ // Process the css={} prop
12091+ let css_info = self . process_css_prop ( element) ;
12092+
12093+ // Walk children
12094+ element. visit_mut_children_with ( self ) ;
12095+ self . walk_jsx_children ( element) ;
12096+
12097+ // Handle xcss attributes and runtime sheets
12098+ let mut runtime_sheets: Vec < String > = Vec :: new ( ) ;
12099+ let mut key_expr: Option < Expr > = None ;
12100+ let mut xcss_transformed = false ;
12101+
12102+ if let Some ( ( sheets, key) ) = css_info {
12103+ if !self . options . extract && !sheets. is_empty ( ) {
12104+ runtime_sheets. extend ( sheets) ;
12105+ }
12106+ key_expr = key;
12107+ if std:: env:: var_os ( "COMPILED_DEBUG_CSS" ) . is_some ( ) {
12108+ eprintln ! (
12109+ "[compiled-debug] visit_mut_jsx_element css_info runtime_sheets={} key_set={}" ,
12110+ runtime_sheets. len( ) ,
12111+ key_expr. is_some( )
12112+ ) ;
12113+ }
12114+ }
12115+
1208212116 if self . options . extract {
1208312117 if let Some ( result) = self . process_xcss_attributes ( element) {
12118+ if !result. runtime_sheets . is_empty ( ) {
12119+ runtime_sheets. extend ( result. runtime_sheets ) ;
12120+ }
1208412121 if !result. pending_class_names . is_empty ( ) {
1208512122 let mut resolved = self . resolve_pending_xcss ( & result. pending_class_names ) ;
12086- if std:: env:: var_os ( "COMPILED_DEBUG_CSS" ) . is_some ( ) && resolved. is_empty ( ) {
12087- eprintln ! ( "[compiled-debug] resolve_pending_xcss produced no sheets" ) ;
12088- }
12123+ runtime_sheets. append ( & mut resolved) ;
12124+ }
12125+ if result. transformed || !result. pending_class_names . is_empty ( ) {
12126+ xcss_transformed = true ;
1208912127 }
1209012128 }
1209112129 }
12092- self . walk_jsx_children ( element) ;
12130+
12131+ if !runtime_sheets. is_empty ( ) {
12132+ if !self . options . extract {
12133+ self . needs_runtime_ax = true ;
12134+ }
12135+ let inner = element. clone ( ) ;
12136+ let wrapper =
12137+ self . build_runtime_component ( Expr :: JSXElement ( Box :: new ( inner) ) , runtime_sheets, key_expr) ;
12138+ // Note: We cannot directly replace the element here. The element is being processed in-place.
12139+ // The wrapper would need to be created at a higher level in visit_mut_expr.
12140+ } else if xcss_transformed {
12141+ // Metadata registrations have already occurred; no runtime wrapper required.
12142+ }
1209312143 }
1209412144}
1209512145
0 commit comments