Revert "babel-types: add Binary alias to AssignmentExpression definition (fixes T6887)"
This was causing problems with parenthesizing assignment expression This reverts commit b5cf529d6b342b3dd8dd49c50cc9cd5fed4fc5a7.
This commit is contained in:
parent
7918b9028b
commit
6abee425d3
@ -155,10 +155,8 @@ export function AssignmentPattern(node: Object) {
|
|||||||
export function AssignmentExpression(node: Object, parent: Object) {
|
export function AssignmentExpression(node: Object, parent: Object) {
|
||||||
// Somewhere inside a for statement `init` node but doesn't usually
|
// Somewhere inside a for statement `init` node but doesn't usually
|
||||||
// needs a paren except for `in` expressions: `for (a in b ? a : b;;)`
|
// needs a paren except for `in` expressions: `for (a in b ? a : b;;)`
|
||||||
// and for `ObjectPattern`: `({ f } = { f: 2 };`
|
|
||||||
let parens = this._inForStatementInit && node.operator === "in" &&
|
let parens = this._inForStatementInit && node.operator === "in" &&
|
||||||
!n.needsParens(node, parent) ||
|
!n.needsParens(node, parent);
|
||||||
t.isObjectPattern(node.left);
|
|
||||||
|
|
||||||
if (parens) {
|
if (parens) {
|
||||||
this.push("(");
|
this.push("(");
|
||||||
|
|||||||
@ -66,7 +66,7 @@ export function Binary(node: Object, parent: Object): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isBinary(parent) && !t.isAssignmentExpression(parent)) {
|
if (t.isBinary(parent)) {
|
||||||
let parentOp = parent.operator;
|
let parentOp = parent.operator;
|
||||||
let parentPos = PRECEDENCE[parentOp];
|
let parentPos = PRECEDENCE[parentOp];
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isBinary(parent) && !t.isAssignmentExpression(parent)) {
|
if (t.isBinary(parent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ defineType("AssignmentExpression", {
|
|||||||
},
|
},
|
||||||
builder: ["operator", "left", "right"],
|
builder: ["operator", "left", "right"],
|
||||||
visitor: ["left", "right"],
|
visitor: ["left", "right"],
|
||||||
aliases: ["Binary", "Expression"]
|
aliases: ["Expression"]
|
||||||
});
|
});
|
||||||
|
|
||||||
defineType("BinaryExpression", {
|
defineType("BinaryExpression", {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user