@@ -275,7 +275,7 @@ let makeExternalDecl fnName loc namedArgListWithKeyAndRef namedTypeList =
275
275
let jsxMapper () =
276
276
let jsxVersion = ref None in
277
277
278
- let transformUppercaseCall3 modulePath mapper loc attrs _ callArguments =
278
+ let transformUppercaseCall3 ~ caller modulePath mapper loc attrs _ callArguments =
279
279
let children, argsWithLabels = extractChildren ~loc ~remove LastPositionUnit:true callArguments in
280
280
let argsForMake = argsWithLabels in
281
281
let childrenExpr = transformChildrenIfListUpper ~loc ~mapper children in
@@ -302,8 +302,8 @@ let jsxMapper () =
302
302
in
303
303
let ident =
304
304
match modulePath with
305
- | Lident _ -> Ldot (modulePath, " make " )
306
- | Ldot (_modulePath , value ) as fullPath when isCap value -> Ldot (fullPath, " make " )
305
+ | Lident _ -> Ldot (modulePath, caller )
306
+ | Ldot (_modulePath , value ) as fullPath when isCap value -> Ldot (fullPath, caller )
307
307
| modulePath -> modulePath
308
308
in
309
309
let propsIdent =
@@ -834,7 +834,7 @@ let jsxMapper () =
834
834
(* Foo.createElement(~prop1=foo, ~prop2=bar, ~children=[], ()) *)
835
835
| { loc; txt = Ldot (modulePath , ("createElement" | "make" )) } -> (
836
836
match ! jsxVersion with
837
- | None | Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
837
+ | None | Some 3 -> transformUppercaseCall3 ~caller: " make " modulePath mapper loc attrs callExpression callArguments
838
838
| Some _ -> raise (Invalid_argument " JSX: the JSX version must be 3" ) )
839
839
(* div(~prop1=foo, ~prop2=bar, ~children=[bla], ()) *)
840
840
(* turn that into
@@ -843,11 +843,13 @@ let jsxMapper () =
843
843
match ! jsxVersion with
844
844
| None | Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
845
845
| Some _ -> raise (Invalid_argument " JSX: the JSX version must be 3" ) )
846
- | { txt = Ldot (_ , anythingNotCreateElementOrMake ) } ->
847
- raise
848
- (Invalid_argument
849
- ( " JSX: the JSX attribute should be attached to a `YourModuleName.createElement` or \
850
- `YourModuleName.make` call. We saw `" ^ anythingNotCreateElementOrMake ^ " ` instead" ))
846
+ (* Foo.bar(~prop1=foo, ~prop2=bar, ~children=[], ()) *)
847
+ (* Not only "createElement" or "make". See
848
+ https://github.com/reasonml/reason/pull/2541 *)
849
+ | { loc; txt = Ldot (modulePath , anythingNotCreateElementOrMake ) } -> (
850
+ match ! jsxVersion with
851
+ | None | Some 3 -> transformUppercaseCall3 ~caller: anythingNotCreateElementOrMake modulePath mapper loc attrs callExpression callArguments
852
+ | Some _ -> raise (Invalid_argument " JSX: the JSX version must be 3" ) )
851
853
| { txt = Lapply _ } ->
852
854
(* don't think there's ever a case where this is reached *)
853
855
raise (Invalid_argument " JSX: encountered a weird case while processing the code. Please report this!" ) )
0 commit comments