File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4514,7 +4514,26 @@ and print_jsx_children ~state (children_expr : Parsetree.expression) ~sep
4514
4514
in
4515
4515
let docs = loop children_expr [] children in
4516
4516
Doc. group (Doc. join ~sep docs)
4517
- | _ -> print_jsx_child ~state children_expr cmt_tbl
4517
+ | _ ->
4518
+ let leading_line_comment_present =
4519
+ has_leading_line_comment cmt_tbl children_expr.pexp_loc
4520
+ in
4521
+ let expr_doc =
4522
+ print_expression_with_comments ~state children_expr cmt_tbl
4523
+ in
4524
+ Doc. concat
4525
+ [
4526
+ Doc. dotdotdot;
4527
+ (match Parens. jsx_child_expr children_expr with
4528
+ | Parenthesized | Braced _ ->
4529
+ let inner_doc =
4530
+ if Parens. braced_expr children_expr then add_parens expr_doc
4531
+ else expr_doc
4532
+ in
4533
+ if leading_line_comment_present then add_braces inner_doc
4534
+ else Doc. concat [Doc. lbrace; inner_doc; Doc. rbrace]
4535
+ | Nothing -> expr_doc);
4536
+ ]
4518
4537
4519
4538
and print_jsx_props ~state args cmt_tbl : Doc.t * Parsetree.expression option =
4520
4539
(* This function was introduced because we have different formatting behavior for self-closing tags and other tags
You can’t perform that action at this time.
0 commit comments