Skip to content

Commit a68fbed

Browse files
committed
Remove unused code
1 parent e0caf83 commit a68fbed

File tree

1 file changed

+0
-82
lines changed

1 file changed

+0
-82
lines changed

compiler/syntax/src/jsx_v4.ml

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,88 +1596,6 @@ let expr ~(config : Jsx_common.jsx_config) mapper expression =
15961596
| _, non_jsx_attributes ->
15971597
transform_jsx_call ~config mapper call_expression call_arguments pexp_loc
15981598
non_jsx_attributes)
1599-
(* is it a list with jsx attribute? Reason <>foo</> desugars to [@JSX][foo]*)
1600-
| {
1601-
pexp_desc =
1602-
( Pexp_construct
1603-
({txt = Lident "::"; loc}, Some {pexp_desc = Pexp_tuple _})
1604-
| Pexp_construct ({txt = Lident "[]"; loc}, None) );
1605-
pexp_attributes;
1606-
} as list_items
1607-
when false -> (
1608-
let jsx_attribute, non_jsx_attributes =
1609-
List.partition
1610-
(fun (attribute, _) -> attribute.txt = "JSX")
1611-
pexp_attributes
1612-
in
1613-
match (jsx_attribute, non_jsx_attributes) with
1614-
(* no JSX attribute *)
1615-
| [], _ -> default_mapper.expr mapper expression
1616-
| _, non_jsx_attributes ->
1617-
let loc = {loc with loc_ghost = true} in
1618-
let fragment =
1619-
match config.mode with
1620-
| "automatic" ->
1621-
Exp.ident ~loc {loc; txt = module_access_name config "jsxFragment"}
1622-
| "classic" | _ ->
1623-
Exp.ident ~loc {loc; txt = Ldot (Lident "React", "fragment")}
1624-
in
1625-
let children_expr = transform_children_if_list ~mapper list_items in
1626-
let record_of_children children =
1627-
Exp.record
1628-
[(Location.mknoloc (Lident "children"), children, false)]
1629-
None
1630-
in
1631-
let apply_jsx_array expr =
1632-
Exp.apply
1633-
(Exp.ident
1634-
{txt = module_access_name config "array"; loc = Location.none})
1635-
[(Nolabel, expr)]
1636-
in
1637-
let count_of_children = function
1638-
| {pexp_desc = Pexp_array children} -> List.length children
1639-
| _ -> 0
1640-
in
1641-
let transform_children_to_props children_expr =
1642-
match children_expr with
1643-
| {pexp_desc = Pexp_array children} -> (
1644-
match children with
1645-
| [] -> empty_record ~loc:Location.none
1646-
| [child] -> record_of_children child
1647-
| _ -> (
1648-
match config.mode with
1649-
| "automatic" -> record_of_children @@ apply_jsx_array children_expr
1650-
| "classic" | _ -> empty_record ~loc:Location.none))
1651-
| _ -> (
1652-
match config.mode with
1653-
| "automatic" -> record_of_children @@ apply_jsx_array children_expr
1654-
| "classic" | _ -> empty_record ~loc:Location.none)
1655-
in
1656-
let args =
1657-
(nolabel, fragment)
1658-
:: (nolabel, transform_children_to_props children_expr)
1659-
::
1660-
(match config.mode with
1661-
| "classic" when count_of_children children_expr > 1 ->
1662-
[(nolabel, children_expr)]
1663-
| _ -> [])
1664-
in
1665-
Exp.apply
1666-
~loc (* throw away the [@JSX] attribute and keep the others, if any *)
1667-
~attrs:non_jsx_attributes
1668-
(* ReactDOM.createElement *)
1669-
(match config.mode with
1670-
| "automatic" ->
1671-
if count_of_children children_expr > 1 then
1672-
Exp.ident ~loc {loc; txt = module_access_name config "jsxs"}
1673-
else Exp.ident ~loc {loc; txt = module_access_name config "jsx"}
1674-
| "classic" | _ ->
1675-
if count_of_children children_expr > 1 then
1676-
Exp.ident ~loc
1677-
{loc; txt = Ldot (Lident "React", "createElementVariadic")}
1678-
else
1679-
Exp.ident ~loc {loc; txt = Ldot (Lident "React", "createElement")})
1680-
args)
16811599
(* Delegate to the default mapper, a deep identity traversal *)
16821600
| e -> default_mapper.expr mapper e
16831601

0 commit comments

Comments
 (0)