Fixup builder-binary-assignment-operator-visitor (#5969)

Using a `SequenceExpression` instead, we avoid awkward
`AssignmentExpression`s as direct children of `BlockStatement`s.
This commit is contained in:
Justin Ridgewell
2017-07-20 11:47:47 -04:00
committed by Henry Zhu
parent 245c78dcdc
commit c60bf9a897
3 changed files with 29 additions and 49 deletions

View File

@@ -32,7 +32,8 @@ function getObjRef(node, nodes, file, scope) {
}
const temp = scope.generateUidIdentifierBasedOnNode(ref);
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, ref)]));
scope.push({ id: temp });
nodes.push(t.assignmentExpression("=", temp, ref));
return temp;
}
@@ -42,7 +43,8 @@ function getPropRef(node, nodes, file, scope) {
if (t.isLiteral(key) && t.isPureish(key)) return key;
const temp = scope.generateUidIdentifierBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, prop)]));
scope.push({ id: temp });
nodes.push(t.assignmentExpression("=", temp, prop));
return temp;
}