diff --git a/crates/oxc_transformer/src/react/jsx/mod.rs b/crates/oxc_transformer/src/react/jsx/mod.rs index 76b3785ef9638..166d0e078bca5 100644 --- a/crates/oxc_transformer/src/react/jsx/mod.rs +++ b/crates/oxc_transformer/src/react/jsx/mod.rs @@ -460,15 +460,6 @@ impl<'a, 'b> JSXElementOrFragment<'a, 'b> { } } - fn attributes(&self) -> Option<&'b Vec<'a, JSXAttributeItem<'a>>> { - match self { - Self::Element(e) if !e.opening_element.attributes.is_empty() => { - Some(&e.opening_element.attributes) - } - _ => None, - } - } - fn children(&self) -> &'b Vec<'a, JSXChild<'a>> { match self { Self::Element(e) => &e.children, @@ -534,21 +525,19 @@ impl<'a> ReactJsx<'a> { // The key prop in `
` let mut key_prop = None; - let attributes = e.attributes(); - let attributes_len = attributes.map_or(0, |attrs| attrs.len()); - // The object properties for the second argument of `React.createElement` let mut properties = self.ast().new_vec(); let mut self_attr_span = None; let mut source_attr_span = None; - if let Some(attributes) = attributes { + if let JSXElementOrFragment::Element(e) = e { + let attributes = &e.opening_element.attributes; for attribute in attributes { match attribute { // optimize `{...prop}` to `prop` in static mode JSXAttributeItem::SpreadAttribute(spread) - if is_classic && attributes_len == 1 => + if is_classic && attributes.len() == 1 => { // deopt if spreading an object with `__proto__` key if !matches!(&spread.argument, Expression::ObjectExpression(o) if o.has_proto())