@@ -1111,7 +1111,7 @@ let reactComponentSignatureTransform mapper signatures =
1111
1111
List. fold_right (transformComponentSignature mapper) signatures []
1112
1112
[@@ raises Invalid_argument ]
1113
1113
1114
- let transformJsxCall jsxVersion mapper callExpression callArguments attrs =
1114
+ let transformJsxCall mapper callExpression callArguments attrs =
1115
1115
match callExpression.pexp_desc with
1116
1116
| Pexp_ident caller -> (
1117
1117
match caller with
@@ -1120,20 +1120,14 @@ let transformJsxCall jsxVersion mapper callExpression callArguments attrs =
1120
1120
(Invalid_argument
1121
1121
" JSX: `createElement` should be preceeded by a module name." )
1122
1122
(* Foo.createElement(~prop1=foo, ~prop2=bar, ~children=[], ()) *)
1123
- | {loc; txt = Ldot (modulePath , ("createElement" | "make" ))} -> (
1124
- match ! jsxVersion with
1125
- | None | Some 3 ->
1126
- transformUppercaseCall3 modulePath mapper loc attrs callExpression
1127
- callArguments
1128
- | Some _ -> raise (Invalid_argument " JSX: the JSX version must be 3" ))
1123
+ | {loc; txt = Ldot (modulePath , ("createElement" | "make" ))} ->
1124
+ transformUppercaseCall3 modulePath mapper loc attrs callExpression
1125
+ callArguments
1129
1126
(* div(~prop1=foo, ~prop2=bar, ~children=[bla], ()) *)
1130
1127
(* turn that into
1131
1128
ReactDOMRe.createElement(~props=ReactDOMRe.props(~props1=foo, ~props2=bar, ()), [|bla|]) *)
1132
- | {loc; txt = Lident id } -> (
1133
- match ! jsxVersion with
1134
- | None | Some 3 ->
1135
- transformLowercaseCall3 mapper loc attrs callExpression callArguments id
1136
- | Some _ -> raise (Invalid_argument " JSX: the JSX version must be 3" ))
1129
+ | {loc; txt = Lident id } ->
1130
+ transformLowercaseCall3 mapper loc attrs callExpression callArguments id
1137
1131
| {txt = Ldot (_ , anythingNotCreateElementOrMake )} ->
1138
1132
raise
1139
1133
(Invalid_argument
@@ -1165,7 +1159,7 @@ let structure nestedModules mapper structure =
1165
1159
@@ reactComponentTransform nestedModules mapper structures
1166
1160
[@@ raises Invalid_argument ]
1167
1161
1168
- let expr jsxVersion mapper expression =
1162
+ let expr mapper expression =
1169
1163
match expression with
1170
1164
(* Does the function application have the @JSX attribute? *)
1171
1165
| {pexp_desc = Pexp_apply (callExpression, callArguments); pexp_attributes}
@@ -1179,8 +1173,7 @@ let expr jsxVersion mapper expression =
1179
1173
(* no JSX attribute *)
1180
1174
| [] , _ -> default_mapper.expr mapper expression
1181
1175
| _ , nonJSXAttributes ->
1182
- transformJsxCall jsxVersion mapper callExpression callArguments
1183
- nonJSXAttributes)
1176
+ transformJsxCall mapper callExpression callArguments nonJSXAttributes)
1184
1177
(* is it a list with jsx attribute? Reason <>foo</> desugars to [@JSX][foo]*)
1185
1178
| {
1186
1179
pexp_desc =
@@ -1231,10 +1224,8 @@ let module_binding nestedModules mapper module_binding =
1231
1224
1232
1225
(* TODO: some line number might still be wrong *)
1233
1226
let jsxMapper nestedModules =
1234
- let jsxVersion = ref None in
1235
1227
let structure = structure nestedModules in
1236
1228
let module_binding = module_binding nestedModules in
1237
- let expr = expr jsxVersion in
1238
1229
{default_mapper with structure; expr; signature; module_binding}
1239
1230
[@@ raises Invalid_argument , Failure ]
1240
1231
0 commit comments