Fix minified labeledStatement printing
Unary expressions with alphabetic operators like 'void' were being squished next to the statement.
This commit is contained in:
parent
b7aa49d9f5
commit
0d9459dbb6
@ -1,6 +1,8 @@
|
||||
import repeating from "repeating";
|
||||
import * as t from "babel-types";
|
||||
|
||||
const NON_ALPHABETIC_UNARY_OPERATORS = t.UPDATE_OPERATORS.concat(t.NUMBER_UNARY_OPERATORS).concat(['!']);
|
||||
|
||||
export function WithStatement(node: Object) {
|
||||
this.keyword("with");
|
||||
this.push("(");
|
||||
@ -107,8 +109,9 @@ function buildLabelStatement(prefix, key = "label") {
|
||||
|
||||
let label = node[key];
|
||||
if (label) {
|
||||
if (!(this.format.minified && (t.isUnaryExpression(label, { prefix: true }) ||
|
||||
t.isUpdateExpression(label, { prefix: true })))) {
|
||||
if (!(this.format.minified && ((t.isUnaryExpression(label, { prefix: true }) ||
|
||||
t.isUpdateExpression(label, { prefix: true })) &&
|
||||
NON_ALPHABETIC_UNARY_OPERATORS.indexOf(label.operator) > -1))) {
|
||||
this.push(" ");
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ function x() {
|
||||
return -1;
|
||||
return --i;
|
||||
return !2;
|
||||
return void 0;
|
||||
}
|
||||
|
||||
throw -1;
|
||||
|
||||
@ -1 +1 @@
|
||||
function x(){return-1;return--i;return!2}throw-1;
|
||||
function x(){return-1;return--i;return!2;return void 0}throw-1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user