refactor(transformer/react-jsx): use extend instead of for-in with push (#1236)

This commit is contained in:
Dunqing 2023-11-12 19:26:15 +08:00 committed by GitHub
parent 47ba874f4f
commit d62631e239
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -335,7 +335,7 @@ impl<'a> ReactJsx<'a> {
} }
// The object properties for the second argument of `React.createElement` // The object properties for the second argument of `React.createElement`
let mut properties = self.ast.new_vec_with_capacity(0); let mut properties = self.ast.new_vec();
if let Some(attributes) = attributes { if let Some(attributes) = attributes {
// TODO: compute the correct capacity for both runtimes // TODO: compute the correct capacity for both runtimes
@ -585,9 +585,7 @@ impl<'a> ReactJsx<'a> {
} }
JSXAttributeItem::SpreadAttribute(attr) => match &attr.argument { JSXAttributeItem::SpreadAttribute(attr) => match &attr.argument {
Expression::ObjectExpression(expr) if !expr.has_proto() => { Expression::ObjectExpression(expr) if !expr.has_proto() => {
for object_property in &expr.properties { properties.extend(self.ast.copy(&expr.properties));
properties.push(self.ast.copy(object_property));
}
} }
expr => { expr => {
let argument = self.ast.copy(expr); let argument = self.ast.copy(expr);