Revert "Ternary Operators in JSX Expression Containers (#4731)" (#4736)

This reverts commit 12046cd01b.
master
Suchipi 2018-06-22 10:32:38 -06:00 committed by GitHub
parent 12046cd01b
commit cb5e1db4a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 32 deletions

View File

@ -243,8 +243,7 @@ function formatTernaryOperator(path, options, print, operatorOptions) {
(operatorOpts.shouldCheckJsx && isJSXNode(n[operatorOpts.testNode])) ||
isJSXNode(n[operatorOpts.consequentNode]) ||
isJSXNode(n[operatorOpts.alternateNode]) ||
conditionalExpressionChainContainsJSX(lastConditionalParent) ||
firstNonConditionalParent.type === "JSXExpressionContainer"
conditionalExpressionChainContainsJSX(lastConditionalParent)
) {
jsxMode = true;
forceNoIndent = true;

View File

@ -240,16 +240,6 @@ cable ? (
)
) : null}
</div>;
// This ConditionalExpression prints in JSX mode because the first
// non-conditional parent is a JSX expression container.
<div>
{data.length > 1 ? (
"This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container."
) : (
"This is string however, is not as long as the previous one."
)}
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// There are two ways to print ConditionalExpressions: "normal mode" and
// "JSX mode". This is normal mode (when breaking):
@ -395,16 +385,6 @@ cable ? (
) : null}
</div>;
// This ConditionalExpression prints in JSX mode because the first
// non-conditional parent is a JSX expression container.
<div>
{data.length > 1 ? (
"This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container."
) : (
"This is string however, is not as long as the previous one."
)}
</div>;
`;
exports[`expression.js 1`] = `

View File

@ -129,13 +129,3 @@ cable ? (
)
) : null}
</div>;
// This ConditionalExpression prints in JSX mode because the first
// non-conditional parent is a JSX expression container.
<div>
{data.length > 1 ? (
"This is a really long non-jsx element inside of a ternary-operator that in turn is inside of a JSX expression container."
) : (
"This is string however, is not as long as the previous one."
)}
</div>