refactor(transformer): simplify match in JSX transform (#5859)

Pure refactor. Reduce match to 1 arm per variant.
This commit is contained in:
overlookmotel 2024-09-19 06:19:10 +00:00
parent a111bb69af
commit 58a83274fd

View file

@ -464,9 +464,8 @@ impl<'a> ReactJsx<'a> {
for attribute in attributes {
match attribute {
// optimize `{...prop}` to `prop` in static mode
JSXAttributeItem::SpreadAttribute(spread)
if is_classic && attributes.len() == 1 =>
{
JSXAttributeItem::SpreadAttribute(spread) => {
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())
{
@ -477,6 +476,7 @@ impl<'a> ReactJsx<'a> {
continue;
}
}
}
JSXAttributeItem::Attribute(attr) => {
if attr.is_identifier("__self") {
self_attr_span = Some(attr.name.span());
@ -496,7 +496,6 @@ impl<'a> ReactJsx<'a> {
}
}
}
JSXAttributeItem::SpreadAttribute(_) => {}
}
// Add attribute to prop object