Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit df8fd28

Browse files
committed
Revert "fix fragment optional children"
This reverts commit 9b129d7.
1 parent 9b129d7 commit df8fd28

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

cli/reactjs_jsx_v4.ml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,22 +1368,24 @@ let expr ~config mapper expression =
13681368
Exp.ident ~loc {loc; txt = Ldot (Lident "React", "fragment")}
13691369
in
13701370
let childrenExpr = transformChildrenIfList ~mapper listItems in
1371-
let recordOfChildren children =
1372-
Exp.record [(Location.mknoloc (Lident "children"), children)] None
1373-
in
13741371
let args =
13751372
[
13761373
(nolabel, fragment);
13771374
(match config.mode with
1378-
| "automatic" -> (
1375+
| "automatic" ->
13791376
( nolabel,
1380-
match childrenExpr with
1381-
| {pexp_desc = Pexp_array children} -> (
1382-
match children with
1383-
| [] -> emptyRecord ~loc:Location.none
1384-
| [child] -> recordOfChildren child
1385-
| _ -> recordOfChildren childrenExpr)
1386-
| _ -> recordOfChildren childrenExpr ))
1377+
Exp.record
1378+
[
1379+
( Location.mknoloc @@ Lident "children",
1380+
match childrenExpr with
1381+
| {pexp_desc = Pexp_array children} -> (
1382+
match children with
1383+
| [] -> emptyRecord ~loc:Location.none
1384+
| [child] -> child
1385+
| _ -> childrenExpr)
1386+
| _ -> childrenExpr );
1387+
]
1388+
None )
13871389
| "classic" | _ -> (nolabel, childrenExpr));
13881390
]
13891391
in

tests/ppx/react/expected/fragment.res.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ let _ = ReactDOM.createDOMElementVariadic("div", [ReactDOM.createDOMElementVaria
1010

1111
@@jsxConfig({version: 4, mode: "automatic"})
1212

13-
let _ = React.jsx(React.jsxFragment, {})
13+
let _ = React.jsx(React.jsxFragment, {children: {}})
1414
let _ = React.jsx(React.jsxFragment, {children: ReactDOM.jsx("div", {})})
15-
let _ = React.jsx(React.jsxFragment, {children: React.jsx(React.jsxFragment, {})})
15+
let _ = React.jsx(React.jsxFragment, {children: React.jsx(React.jsxFragment, {children: {}})})
1616
let _ = React.jsx(Z.make, {})
1717
let _ = React.jsx(Z.make, {children: ReactDOM.jsx("div", {})})
1818
let _ = ReactDOM.jsx("div", {})

0 commit comments

Comments
 (0)