Skip to content

Commit 8deb5ec

Browse files
committed
Revert "allow simplified @@jsxConfig"
This reverts commit 7dcd211.
1 parent 084f176 commit 8deb5ec

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

jscomp/syntax/src/jsx_ppx.ml

+13-34
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,16 @@ open Asttypes
33
open Parsetree
44
open Longident
55

6-
type configPayload =
7-
| ModuleName of string
8-
| Fields of (t loc * expression) list
9-
| Invalid
10-
11-
let getConfigPayload payload =
6+
let getPayloadFields payload =
127
match payload with
138
| PStr
149
({
1510
pstr_desc =
1611
Pstr_eval ({pexp_desc = Pexp_record (recordFields, None)}, _);
1712
}
1813
:: _rest) ->
19-
Fields recordFields
20-
| PStr
21-
({
22-
pstr_desc =
23-
Pstr_eval
24-
({pexp_desc = Pexp_constant (Pconst_string (moduleName, _))}, _);
25-
}
26-
:: _rest) ->
27-
ModuleName moduleName
28-
| _ -> Invalid
14+
recordFields
15+
| _ -> []
2916

3017
type configKey = Int | String
3118

@@ -60,24 +47,16 @@ let getInt ~key fields =
6047
let getString ~key fields = fields |> getJsxConfigByKey ~key ~type_:String
6148

6249
let updateConfig config payload =
63-
match getConfigPayload payload with
64-
| Invalid -> () (* TODO(generic-jsx): Report error? *)
65-
| ModuleName moduleName ->
66-
config.Jsx_common.module_ <- moduleName;
67-
if String.lowercase_ascii moduleName <> "react" then (
68-
(* Force set automatic/version for anything but React *)
69-
config.version <- 4;
70-
config.mode <- "automatic")
71-
| Fields fields -> (
72-
(match getInt ~key:"version" fields with
73-
| None -> ()
74-
| Some i -> config.Jsx_common.version <- i);
75-
(match getString ~key:"module_" fields with
76-
| None -> ()
77-
| Some s -> config.module_ <- s);
78-
match getString ~key:"mode" fields with
79-
| None -> ()
80-
| Some s -> config.mode <- s)
50+
let fields = getPayloadFields payload in
51+
(match getInt ~key:"version" fields with
52+
| None -> ()
53+
| Some i -> config.Jsx_common.version <- i);
54+
(match getString ~key:"module_" fields with
55+
| None -> ()
56+
| Some s -> config.module_ <- s);
57+
match getString ~key:"mode" fields with
58+
| None -> ()
59+
| Some s -> config.mode <- s
8160

8261
let isJsxConfigAttr ((loc, _) : attribute) = loc.txt = "jsxConfig"
8362

jscomp/syntax/src/jsx_v4.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
502502
let domBinding =
503503
match moduleAccessName config with
504504
| "React" -> Lident "ReactDOM"
505-
| generic -> Ldot (Lident generic, "Elements")
505+
| generic -> Ldot (Lident generic, "DOM")
506506
in
507507

508508
let children, nonChildrenProps =

0 commit comments

Comments
 (0)