Skip to content

Commit 612251d

Browse files
Copilottsnobip
andcommitted
Wrap variables in braces inside JSX children
Co-authored-by: tsnobip <[email protected]>
1 parent 5f80eac commit 612251d

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

compiler/syntax/src/res_parens.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ let jsx_child_expr expr =
373373
| _ when ParsetreeViewer.expr_is_await expr -> Parenthesized
374374
| {
375375
Parsetree.pexp_desc =
376-
( Pexp_ident _ | Pexp_constant _ | Pexp_field _ | Pexp_construct _
376+
( Pexp_constant _ | Pexp_field _ | Pexp_construct _
377377
| Pexp_variant _ | Pexp_array _ | Pexp_pack _ | Pexp_record _
378378
| Pexp_extension _ | Pexp_letmodule _ | Pexp_letexception _
379379
| Pexp_open _ | Pexp_sequence _ | Pexp_let _ | Pexp_jsx_element _ );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Cite = {
33
let make = (~author: option<string>, ~children) => {
44
// For semantics, check out
55
// https://css-tricks.com/quoting-in-html-quotations-citations-and-blockquotes/
6-
<div> foo </div>
6+
<div> {foo} </div>
77
}
88
}
99

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ apply({
282282
a
283283
})
284284

285-
let x = {<div> child </div>}
285+
let x = {<div> {child} </div>}
286286

287287
// not valid jsx
288288
let x = {@JSX child}

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

tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let make = (~min=50, ~max=250, ~meterSuffix=?) => {
3434
values
3535
onChange={v => values_set(_ => v)}
3636
renderTrack={({props, children}) => {
37-
let element = <div className="h-16" style=props.style> children </div>
37+
let element = <div className="h-16" style=props.style> {children} </div>
3838

3939
ReasonReact.cloneElement(element, ~props=Obj.magic(props), [children])
4040
}}

0 commit comments

Comments
 (0)