Skip to content

Commit 73a519a

Browse files
committed
Preserve snake case for area labels
1 parent ba16895 commit 73a519a

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

compiler/core/js_dump.ml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,20 +1154,10 @@ and print_jsx cxt ?(spread_props : J.expression option)
11541154
in
11551155

11561156
let print_prop n x ctx =
1157-
let n =
1158-
(* turn aria-label to ariaLabel *)
1159-
if not (String.contains n '-') then n
1160-
else
1161-
let chars = String.to_seq n |> List.of_seq in
1162-
let rec visit chars acc =
1163-
match chars with
1164-
| [] -> List.rev acc
1165-
| '-' :: l :: rest -> visit rest (Char.uppercase_ascii l :: acc)
1166-
| c :: rest -> visit rest (c :: acc)
1167-
in
1168-
visit chars [] |> List.to_seq |> String.of_seq
1157+
let prop_name =
1158+
if String.starts_with ~prefix:"aria-" n then n
1159+
else Js_dump_property.property_key_string n
11691160
in
1170-
let prop_name = Js_dump_property.property_key_string n in
11711161
P.string f prop_name;
11721162
P.string f "=";
11731163
print_prop_value x ctx

tests/tests/src/jsx_preserve_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ let _optional_props = <Jsx_preserve_test$ComponentWithOptionalProps
204204
/>;
205205

206206
let _props_with_hypen = <label
207-
ariaLabel="close sidebar"
207+
aria-label="close sidebar"
208208
/>;
209209

210210
export {

0 commit comments

Comments
 (0)