Skip to content

Commit

Permalink
refactor(transformer): shorten code in JSX transform (#5554)
Browse files Browse the repository at this point in the history
Pure refactor. Just shorten code.
  • Loading branch information
overlookmotel committed Sep 6, 2024
1 parent 28b934c commit ce71982
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions crates/oxc_transformer/src/react/jsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,13 @@ impl<'a> Traverse<'a> for ReactJsx<'a> {
}

fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
let new_expr = match expr {
Expression::JSXElement(e) => {
Some(self.transform_jsx(&JSXElementOrFragment::Element(e), ctx))
}
*expr = match expr {
Expression::JSXElement(e) => self.transform_jsx(&JSXElementOrFragment::Element(e), ctx),
Expression::JSXFragment(e) => {
Some(self.transform_jsx(&JSXElementOrFragment::Fragment(e), ctx))
self.transform_jsx(&JSXElementOrFragment::Fragment(e), ctx)
}
_ => None,
_ => return,
};

if let Some(new_expr) = new_expr {
*expr = new_expr;
}
}
}

Expand Down

0 comments on commit ce71982

Please sign in to comment.