Don't add () in JSX attributes with elements (#3640)

master
Lucas Duailibe 2018-01-03 11:36:25 -03:00 committed by GitHub
parent 6260629f18
commit 7d3a30615b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -4477,6 +4477,7 @@ function maybeWrapJSXElementInParens(path, elem) {
const NO_WRAP_PARENTS = {
ArrayExpression: true,
JSXAttribute: true,
JSXElement: true,
JSXExpressionContainer: true,
JSXFragment: true,

View File

@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`attr-element.js 1`] = `
<Foo prop=<Bar><Baz /></Bar> />;
<Foo prop=<><Bar><Baz /></Bar></> />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Foo
prop=<Bar>
<Baz />
</Bar>
/>;
<Foo
prop=<>
<Bar>
<Baz />
</Bar>
</>
/>;
`;

View File

@ -0,0 +1,2 @@
<Foo prop=<Bar><Baz /></Bar> />;
<Foo prop=<><Bar><Baz /></Bar></> />;

View File

@ -0,0 +1,2 @@
// Flow and TypeScript don't support JSX elements as attribute values
run_spec(__dirname, ["babylon"]);