Add parens for ConditionalExpression inside JSXSpreadAttribute (#1015)

This commit is contained in:
Brian Ng authored and Christopher Chedeau committed 2017-03-15 18:52:31 -07:00
1 parent c82bb4e003
commit b8a7e5166b
3 files changed
+11

No files matched your search

+1
View File
@@ -440,6 +440,7 @@ FPp.needsParens = function(assumeExpressionContext) {
case "LogicalExpression":
case "ExportDefaultDeclaration":
case "AwaitExpression":
case "JSXSpreadAttribute":
return true;
case "NewExpression":
@@ -551,6 +551,8 @@ exports[`parens.js 1`] = `
d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,'
/>,
];
<div {...((foo || foo === null) ? {foo} : null)} />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = [
<path
@@ -562,6 +564,8 @@ a = [
d=\\"M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,\\"
/>
];
<div {...foo || foo === null ? { foo } : null} />;
"
`;
@@ -576,6 +580,8 @@ exports[`parens.js 2`] = `
d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,'
/>,
];
<div {...((foo || foo === null) ? {foo} : null)} />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = [
<path
@@ -587,6 +593,8 @@ a = [
d=\\"M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,\\"
/>
];
<div {...foo || foo === null ? { foo } : null} />;
"
`;
+2
View File
@@ -8,3 +8,5 @@ a = [
d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,'
/>,
];
<div {...((foo || foo === null) ? {foo} : null)} />