Chromium Code Reviews| Index: lib/src/js/printer.dart |
| diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart |
| index f95a64d976700c0dd8e53d18230015aaf9fb1781..fbb12ce852e939534d719b527bca44d834c3d758 100644 |
| --- a/lib/src/js/printer.dart |
| +++ b/lib/src/js/printer.dart |
| @@ -861,8 +861,14 @@ class Printer implements NodeVisitor { |
| out("=>"); |
| if (fun.body is Expression) { |
| spaceOut(); |
| + // Object initializers require parenthesis to disambiguate |
| + // AssignmentExpression from FunctionBody. See: |
| + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-arrow-function-defi... |
|
Jennifer Messerly
2015/05/19 22:49:48
`sec-arrow-function-definitions` seems to have got
Leaf
2015/05/19 23:24:07
Done.
|
| + var needsParen = fun.body is ObjectInitializer; |
| + if (needsParen) out("("); |
| visitNestedExpression(fun.body, ASSIGNMENT, |
| newInForInit: false, newAtStatementBegin: false); |
| + if (needsParen) out(")"); |
| } else { |
| blockBody(fun.body, needsSeparation: false, needsNewline: false); |
| } |
| @@ -920,14 +926,11 @@ class Printer implements NodeVisitor { |
| } |
| visitObjectInitializer(ObjectInitializer node) { |
| - // Print all the properties on one line until we see a function-valued |
| - // property. Ideally, we would use a proper pretty-printer to make the |
| - // decision based on layout. |
| List<Property> properties = node.properties; |
| out("{"); |
| indentMore(); |
| - var isOneLiner = !properties.any((p) => p.value is FunctionExpression); |
| + var isOneLiner = !node.vertical; |
| for (int i = 0; i < properties.length; i++) { |
| if (i != 0) { |
| out(","); |