Skip to content

Commit bbfe816

Browse files
committed
Map prop value
1 parent 84e9cbe commit bbfe816

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

compiler/ml/ast_mapper_from0.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ module E = struct
360360
when name = v ->
361361
Some
362362
(Parsetree.JSXPropPunning (true, {txt = name; loc = name_loc}))
363+
| Asttypes.Noloc.Labelled name, exp ->
364+
Some
365+
(Parsetree.JSXPropValue
366+
( {txt = name; loc = Location.none},
367+
false,
368+
sub.expr sub exp ))
369+
| Asttypes.Noloc.Optional name, exp ->
370+
Some
371+
(Parsetree.JSXPropValue
372+
({txt = name; loc = Location.none}, true, sub.expr sub exp))
363373
| _ -> None)
364374
in
365375
jsx_unary_element ~loc ~attrs tag_name props

compiler/ml/ast_mapper_to0.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ module E = struct
465465
else Asttypes.Noloc.Labelled name.txt
466466
in
467467
(label, ident)
468+
| JSXPropValue (name, is_optional, value) ->
469+
let label =
470+
if is_optional then Asttypes.Noloc.Optional name.txt
471+
else Asttypes.Noloc.Labelled name.txt
472+
in
473+
(label, sub.expr sub value)
468474
| _ -> failwith "todo")
469475
in
470476
let children_expr =

0 commit comments

Comments
 (0)