Skip to content

Commit b4f3095

Browse files
Copilottsnobip
andcommitted
Fix spread variables wrapping in JSX children
Co-authored-by: tsnobip <2479216+tsnobip@users.noreply.github.com>
1 parent 612251d commit b4f3095

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/syntax/src/res_parens.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ let jsx_child_expr expr =
371371
when starts_with_minus x ->
372372
Parenthesized
373373
| _ when ParsetreeViewer.expr_is_await expr -> Parenthesized
374+
| _ when ParsetreeViewer.has_spread_attr expr.pexp_attributes -> Parenthesized
374375
| {
375376
Parsetree.pexp_desc =
376377
( Pexp_constant _ | Pexp_field _ | Pexp_construct _

tests/syntax_tests/data/printer/expr/expected/jsx.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ let x =
209209

210210
let x =
211211
<div>
212-
{ident}
212+
ident
213213
"constant"
214214
{
215215
let a = 1
@@ -492,14 +492,14 @@ let fragmented_moo =
492492

493493
let arrow_with_fragment = el => <>
494494
{t(nbsp ++ "(")}
495-
{el}
495+
el
496496
{t(")")}
497497
</>
498498

499499
let arrow_with_container_tag = el =>
500500
<div>
501501
{t(nbsp ++ "(")}
502-
{el}
502+
el
503503
{t(")")}
504504
</div>
505505

0 commit comments

Comments
 (0)