Inline do expressions inside of JSX (#3607)

Fixes #3602
master
Christopher Chedeau 2017-12-29 22:58:01 +01:00 committed by Lucas Duailibe
parent cfb8987ecd
commit 7eca8011bc
4 changed files with 23 additions and 0 deletions

View File

@ -1691,6 +1691,7 @@ function printPathNoParens(path, options, print, args) {
n.expression.type === "JSXEmptyExpression" ||
n.expression.type === "TemplateLiteral" ||
n.expression.type === "TaggedTemplateExpression" ||
n.expression.type === "DoExpression" ||
(isJSXNode(parent) &&
(n.expression.type === "ConditionalExpression" ||
isBinaryish(n.expression))));

View File

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`do.js 1`] = `
<div>
{do {
1
}}
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div>
{do {
1;
}}
</div>;
`;

5
tests/jsx-do/do.js Normal file
View File

@ -0,0 +1,5 @@
<div>
{do {
1
}}
</div>

View File

@ -0,0 +1 @@
run_spec(__dirname, ["babylon"]);