Skip to content

Commit db4b047

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

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
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: 4 additions & 4 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
@@ -364,7 +364,7 @@ module App = {
364364
</div>
365365

366366
<Animated> ...{x => <div />} </Animated>
367-
<div> ...c </div>
367+
<div>{...c}</div>
368368

369369
<Animated initialValue=0.0 value>
370370
...{ReactDOMRe.Style.make(
@@ -558,14 +558,14 @@ let fragmented_moo =
558558

559559
let arrow_with_fragment = el => <>
560560
{t(nbsp ++ "(")}
561-
{el}
561+
el
562562
{t(")")}
563563
</>
564564

565565
let arrow_with_container_tag = el =>
566566
<div>
567567
{t(nbsp ++ "(")}
568-
{el}
568+
el
569569
{t(")")}
570570
</div>
571571

0 commit comments

Comments
 (0)