File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -532,17 +532,28 @@ impl VisitMut for JSXMutVisitor {
532532 ] ,
533533 type_args : None ,
534534 } ) ;
535- for attr in & mut n. opening . attrs {
536- if let JSXAttrOrSpread :: JSXAttr ( attr) = attr {
537- if let JSXAttrName :: Ident ( ident) = & attr. name {
538- if ident. sym . to_string ( ) == "style" {
539- attr. value = Some ( JSXAttrValue :: JSXExprContainer ( JSXExprContainer {
540- span : DUMMY_SP ,
541- expr : JSXExpr :: Expr ( Box :: new ( fun_call_expr. clone ( ) ) ) ,
542- } ) ) ;
535+ if has_style {
536+ for attr in & mut n. opening . attrs {
537+ if let JSXAttrOrSpread :: JSXAttr ( attr) = attr {
538+ if let JSXAttrName :: Ident ( ident) = & attr. name {
539+ if ident. sym . to_string ( ) == "style" {
540+ attr. value = Some ( JSXAttrValue :: JSXExprContainer ( JSXExprContainer {
541+ span : DUMMY_SP ,
542+ expr : JSXExpr :: Expr ( Box :: new ( fun_call_expr. clone ( ) ) ) ,
543+ } ) ) ;
544+ }
543545 }
544546 }
545547 }
548+ } else {
549+ n. opening . attrs . push ( JSXAttrOrSpread :: JSXAttr ( JSXAttr {
550+ span : DUMMY_SP ,
551+ name : JSXAttrName :: Ident ( Ident :: new ( "style" . into ( ) , DUMMY_SP ) ) ,
552+ value : Some ( JSXAttrValue :: JSXExprContainer ( JSXExprContainer {
553+ span : DUMMY_SP ,
554+ expr : JSXExpr :: Expr ( Box :: new ( fun_call_expr) ) ,
555+ } ) ) ,
556+ } ) ) ;
546557 }
547558 }
548559 }
You can’t perform that action at this time.
0 commit comments