-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support jsx transform with fragment (#835)
* support jsx transform with fragment * fix children * fix test * wrap in array * add changelog entry --------- Co-authored-by: Antonio Nuno Monteiro <[email protected]>
- Loading branch information
1 parent
992096b
commit fc156dd
Showing
5 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,52 @@ | ||
$ ../ppx.sh --output re input.re | ||
let fragment = foo => | ||
[@bla] ReactDOM.createElement(React.jsxFragment, [|foo|]); | ||
[@bla] | ||
React.jsx( | ||
React.jsxFragment, | ||
([@merlin.hide] ReactDOM.domProps)(~children=React.array([|foo|]), ()), | ||
); | ||
let just_one_child = foo => | ||
React.jsx( | ||
React.jsxFragment, | ||
([@merlin.hide] ReactDOM.domProps)(~children=React.array([|bar|]), ()), | ||
); | ||
let poly_children_fragment = (foo, bar) => | ||
ReactDOM.createElement(React.jsxFragment, [|foo, bar|]); | ||
React.jsx( | ||
React.jsxFragment, | ||
([@merlin.hide] ReactDOM.domProps)( | ||
~children=React.array([|foo, bar|]), | ||
(), | ||
), | ||
); | ||
let nested_fragment = (foo, bar, baz) => | ||
ReactDOM.createElement( | ||
React.jsx( | ||
React.jsxFragment, | ||
[|foo, ReactDOM.createElement(React.jsxFragment, [|bar, baz|])|], | ||
([@merlin.hide] ReactDOM.domProps)( | ||
~children= | ||
React.array([| | ||
foo, | ||
React.jsx( | ||
React.jsxFragment, | ||
([@merlin.hide] ReactDOM.domProps)( | ||
~children=React.array([|bar, baz|]), | ||
(), | ||
), | ||
), | ||
|]), | ||
(), | ||
), | ||
); | ||
let nested_fragment_with_lower = foo => | ||
ReactDOM.createElement( | ||
React.jsx( | ||
React.jsxFragment, | ||
[| | ||
ReactDOM.jsx( | ||
"div", | ||
([@merlin.hide] ReactDOM.domProps)(~children=foo, ()), | ||
), | ||
|], | ||
([@merlin.hide] ReactDOM.domProps)( | ||
~children= | ||
React.array([| | ||
ReactDOM.jsx( | ||
"div", | ||
([@merlin.hide] ReactDOM.domProps)(~children=foo, ()), | ||
), | ||
|]), | ||
(), | ||
), | ||
); |