@@ -104,13 +104,13 @@ impl VisitMut for AppTransformer {
104104 }
105105 }
106106
107- fn visit_mut_jsx_opening_element ( & mut self , elem : & mut JSXOpeningElement ) {
107+ fn visit_mut_jsx_element ( & mut self , elem : & mut JSXElement ) {
108108 elem. visit_mut_children_with ( self ) ;
109109
110110 let mut found = false ;
111111
112112 // find and remove data-superjson directive
113- elem. attrs . retain ( |attr_or_spread| {
113+ elem. opening . attrs . retain ( |attr_or_spread| {
114114 if let JSXAttrOrSpread :: JSXAttr ( JSXAttr {
115115 name : JSXAttrName :: Ident ( id) ,
116116 ..
@@ -127,6 +127,7 @@ impl VisitMut for AppTransformer {
127127 if found {
128128 // attrs -> obj props
129129 let list: Vec < PropOrSpread > = elem
130+ . opening
130131 . attrs
131132 . take ( )
132133 . into_iter ( )
@@ -169,7 +170,7 @@ impl VisitMut for AppTransformer {
169170 . collect ( ) ;
170171
171172 // replace attrs
172- elem. attrs = vec ! [
173+ elem. opening . attrs = vec ! [
173174 JSXAttr {
174175 name: Ident :: new( DESERIALIZER_PROPS_ATTR . into( ) , DUMMY_SP ) . into( ) ,
175176 span: DUMMY_SP ,
@@ -201,7 +202,7 @@ impl VisitMut for AppTransformer {
201202 span: DUMMY_SP ,
202203 value: Some (
203204 JSXExprContainer {
204- expr: Box :: new( elem. name. as_expr( ) ) . into( ) ,
205+ expr: Box :: new( elem. opening . name. as_expr( ) ) . into( ) ,
205206 span: DUMMY_SP ,
206207 }
207208 . into( ) ,
@@ -211,7 +212,12 @@ impl VisitMut for AppTransformer {
211212 ] ;
212213
213214 // change element name
214- elem. name = Ident :: new ( DESERIALIZER_COMPONENT . into ( ) , DUMMY_SP ) . into ( ) ;
215+ elem. opening . name = Ident :: new ( DESERIALIZER_COMPONENT . into ( ) , DUMMY_SP ) . into ( ) ;
216+
217+ if let Some ( closing) = & mut elem. closing {
218+ closing. name = Ident :: new ( DESERIALIZER_COMPONENT . into ( ) , DUMMY_SP ) . into ( ) ;
219+ }
220+
215221 self . transformed = true ;
216222 }
217223 }
0 commit comments