-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JSX fragments #3237
Changes from 8 commits
a370fd2
2f38306
395d74f
deab9d1
6c3e0b3
1910cda
856faf5
54f3e54
fc4d55d
849852c
29b3144
c786439
31a5846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`fragment.js 1`] = ` | ||
<></>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth adding a "complex" nested fragment example (here's the one from Babylon): <div>
<>
<>
<span>Hello</span>
<span>world</span>
</>
<>
<span>Goodbye</span>
<span>world</span>
</>
</>
</div> EDIT: nvm, noticed your comment re: tests in the PR desc |
||
|
||
<> | ||
text | ||
</>; | ||
|
||
<> | ||
<Component /> | ||
<Component /> | ||
</>; | ||
|
||
<> | ||
text | ||
<h2>heading</h2> | ||
text | ||
<h2>heading</h2> | ||
text | ||
</>; | ||
|
||
<div> | ||
<> | ||
<> | ||
<span>Hello</span> | ||
<span>world</span> | ||
</> | ||
<> | ||
<span>Goodbye</span> | ||
<span>world</span> | ||
</> | ||
</> | ||
</div>; | ||
|
||
</* open fragment */> | ||
<Component /> | ||
<Component /> | ||
</ /* close fragment */>; | ||
|
||
< // open fragment | ||
> | ||
<Component /> | ||
<Component /> | ||
</ // close fragment | ||
>; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
<></>; | ||
|
||
<>text</>; | ||
|
||
<> | ||
<Component /> | ||
<Component /> | ||
</>; | ||
|
||
<> | ||
text | ||
<h2>heading</h2> | ||
text | ||
<h2>heading</h2> | ||
text | ||
</>; | ||
|
||
<div> | ||
<> | ||
<> | ||
<span>Hello</span> | ||
<span>world</span> | ||
</> | ||
<> | ||
<span>Goodbye</span> | ||
<span>world</span> | ||
</> | ||
</> | ||
</div>; | ||
|
||
</* open fragment */> | ||
<Component /> | ||
<Component /> | ||
<//* close fragment */>; | ||
|
||
< | ||
// open fragment | ||
> | ||
<Component /> | ||
<Component /> | ||
</ | ||
// close fragment | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a self-closing JSX tag, we would put the "closing slash" after the comment or attributes. Maybe we should do the same thing for fragments? Prettier 1.8.2 Input: <div
/* foo */
/>;
<div
a={a}
b={reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong}
/>; Output: <div
/* foo */
/>;
<div
a={a}
b={reallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong}
/>; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking more of this case: Input: <div>
Text
</div /* comment */>;
<div>
Text
</* comment */ /div>; Output: <div>Text</div /* comment */>;
<div>Text<//* comment */ div>; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you can't put attributes in a jsx fragment (afaik), I guess it only affects comments, so it's probably fine either way |
||
>; | ||
|
||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<></>; | ||
|
||
<> | ||
text | ||
</>; | ||
|
||
<> | ||
<Component /> | ||
<Component /> | ||
</>; | ||
|
||
<> | ||
text | ||
<h2>heading</h2> | ||
text | ||
<h2>heading</h2> | ||
text | ||
</>; | ||
|
||
<div> | ||
<> | ||
<> | ||
<span>Hello</span> | ||
<span>world</span> | ||
</> | ||
<> | ||
<span>Goodbye</span> | ||
<span>world</span> | ||
</> | ||
</> | ||
</div>; | ||
|
||
</* open fragment */> | ||
<Component /> | ||
<Component /> | ||
</ /* close fragment */>; | ||
|
||
< // open fragment | ||
> | ||
<Component /> | ||
<Component /> | ||
</ // close fragment | ||
>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_spec(__dirname); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we turn on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh... thanks for catching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I fixed before merging... lucky :-)