File tree 5 files changed +37
-4
lines changed
5 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -1124,7 +1124,9 @@ and print_jsx cxt ?(spread_props : J.expression option)
1124
1124
else
1125
1125
(List. fold_left (fun acc (n , x ) ->
1126
1126
P. space f;
1127
- P. string f n;
1127
+ let prop_name = Js_dump_property. property_key_string n in
1128
+
1129
+ P. string f prop_name;
1128
1130
P. string f " =" ;
1129
1131
P. string f " {" ;
1130
1132
let next = expression ~level: 0 acc f x in
Original file line number Diff line number Diff line change @@ -81,9 +81,11 @@ let property_access f s =
81
81
| _ -> Js_dump_string. pp_string f s
82
82
| exception _ -> Js_dump_string. pp_string f s)
83
83
84
+ let property_key_string (s : string ) : string =
85
+ let s = Ext_ident. unwrap_uppercase_exotic s in
86
+ if obj_property_no_need_quot s then s else Js_dump_string. escape_to_string s
87
+
84
88
let property_key (s : J.property_name ) : string =
85
89
match s with
86
- | Lit s ->
87
- let s = Ext_ident. unwrap_uppercase_exotic s in
88
- if obj_property_no_need_quot s then s else Js_dump_string. escape_to_string s
90
+ | Lit s -> property_key_string s
89
91
| Symbol_name -> {| [Symbol. for (" name" )]| }
Original file line number Diff line number Diff line change 25
25
val property_access : Ext_pp .t -> string -> unit
26
26
27
27
val property_key : J .property_name -> string
28
+
29
+ val property_key_string : string -> string
Original file line number Diff line number Diff line change @@ -111,6 +111,19 @@ let _external_component_with_children = <QueryClientProvider>
111
111
< Preserve_jsx_test$B />
112
112
</ QueryClientProvider > ;
113
113
114
+ function make ( props ) {
115
+ return < p >
116
+ { "foo" }
117
+ { props [ "\\\"MyWeirdProp\"" ] }
118
+ </ p > ;
119
+ }
120
+
121
+ let MyWeirdComponent = {
122
+ make : make
123
+ } ;
124
+
125
+ let _escaped_jsx_prop = < make MyWeirdProp = { "bar" } /> ;
126
+
114
127
export {
115
128
React ,
116
129
ReactDOM ,
@@ -133,5 +146,7 @@ export {
133
146
A ,
134
147
B ,
135
148
_external_component_with_children ,
149
+ MyWeirdComponent ,
150
+ _escaped_jsx_prop ,
136
151
}
137
152
/* _single_element_child Not a pure module */
Original file line number Diff line number Diff line change @@ -155,3 +155,15 @@ let _external_component_with_children =
155
155
<strong />
156
156
<B />
157
157
</A >
158
+
159
+ module MyWeirdComponent = {
160
+ type props = {\"MyWeirdProp" : string }
161
+
162
+ let make = props =>
163
+ <p >
164
+ {React .string ("foo" )}
165
+ {React .string (props .\"MyWeirdProp" )}
166
+ </p >
167
+ }
168
+
169
+ let _escaped_jsx_prop = <MyWeirdComponent \"MyWeirdProp" = "bar" />
You can’t perform that action at this time.
0 commit comments