Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e549c37ca1 | ||
|
|
02512da38d | ||
|
|
abe9c4fd30 | ||
|
|
af21c52cc6 | ||
|
|
706626f79a |
@@ -2,6 +2,11 @@
|
||||
|
||||
Gaps between patch versions are faulty/broken releases.
|
||||
|
||||
## 2.4.1
|
||||
|
||||
* Better whitespace handling of parenthesized expressions due to trailing comments.
|
||||
* Fix `yield` inside of comprehensions.
|
||||
|
||||
## 2.4.0
|
||||
|
||||
* Use a closure always for classes with a super.
|
||||
|
||||
@@ -148,10 +148,11 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
};
|
||||
|
||||
if (this[node.type]) {
|
||||
// only compute if this node needs parens if our parent has been changed
|
||||
// since acorn would've wrapped us in a ParanthesizedExpression
|
||||
var needsParens = n.needsParens(node, parent);
|
||||
var needsCommentParens = t.isExpression(node) && node.leadingComments && node.leadingComments.length;
|
||||
var needsParens = needsCommentParens || n.needsParens(node, parent);
|
||||
|
||||
if (needsParens) this.push("(");
|
||||
if (needsCommentParens) this.indent();
|
||||
|
||||
this.printLeadingComments(node, parent);
|
||||
|
||||
@@ -162,6 +163,10 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
|
||||
this[node.type](node, this.buildPrint(node), parent);
|
||||
|
||||
if (needsCommentParens) {
|
||||
this.newline();
|
||||
this.dedent();
|
||||
}
|
||||
if (needsParens) this.push(")");
|
||||
|
||||
this.map.mark(node, "end");
|
||||
|
||||
@@ -60,10 +60,6 @@ Node.prototype.needsParens = function () {
|
||||
|
||||
if (!parent) return false;
|
||||
|
||||
if (t.isExpression(node) && node.leadingComments && node.leadingComments.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isNewExpression(parent) && parent.callee === node) {
|
||||
return t.isCallExpression(node) || _.some(node, function (val) {
|
||||
return t.isCallExpression(val);
|
||||
|
||||
@@ -16,7 +16,7 @@ var build = function (node, file) {
|
||||
var body = block.body;
|
||||
|
||||
if (traverse.hasType(node, "YieldExpression", t.FUNCTION_TYPES)) {
|
||||
container.generator = true;
|
||||
container.callee.generator = true;
|
||||
container = t.yieldExpression(container, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
@@ -6,5 +6,6 @@ var test = {
|
||||
[( /*
|
||||
* Inside bracket init
|
||||
*/
|
||||
"b")]: "2"
|
||||
"b"
|
||||
)]: "2"
|
||||
}, ok = 42;
|
||||
|
||||
@@ -7,7 +7,8 @@ var test = {
|
||||
[( /*
|
||||
* Inside bracket init
|
||||
*/
|
||||
"b")]: "2",
|
||||
"b"
|
||||
)]: "2",
|
||||
|
||||
["c"
|
||||
/*
|
||||
@@ -18,8 +19,9 @@ var test = {
|
||||
["d"]: "4",
|
||||
|
||||
[(
|
||||
// Inside bracket, line comment
|
||||
"e")]: "5",
|
||||
// Inside bracket, line comment
|
||||
"e"
|
||||
)]: "5",
|
||||
|
||||
["f"
|
||||
// After bracket, line comment
|
||||
|
||||
Reference in New Issue
Block a user