check if a node is static before using it as the reference for an object spread
This commit is contained in:
parent
8128b35e25
commit
3961b720be
@ -460,8 +460,8 @@ class DestructuringTransformer {
|
||||
// member expression then we need to assign it to a temporary variable so it's
|
||||
// only evaluated once
|
||||
|
||||
if (pattern.properties.length > 1 && t.isMemberExpression(objRef)) {
|
||||
var temp = this.scope.generateUidIdentifierBasedOnNode(objRef, this.file);
|
||||
if (pattern.properties.length > 1 && !this.scope.isStatic(objRef)) {
|
||||
var temp = this.scope.generateUidIdentifierBasedOnNode(objRef);
|
||||
this.nodes.push(this.buildVariableDeclaration(temp, objRef));
|
||||
objRef = temp;
|
||||
}
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
var rect = {};
|
||||
var {topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}} = rect;
|
||||
var { 3: foo, 5: bar } = [0, 1, 2, 3, 4, 5, 6];
|
||||
|
||||
@ -7,3 +7,6 @@ var y1 = _rect$topLeft.y;
|
||||
var _rect$bottomRight = rect.bottomRight;
|
||||
var x2 = _rect$bottomRight.x;
|
||||
var y2 = _rect$bottomRight.y;
|
||||
var _ref = [0, 1, 2, 3, 4, 5, 6];
|
||||
var foo = _ref[3];
|
||||
var bar = _ref[5];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user