diff --git a/CHANGELOG.md b/CHANGELOG.md index f5cb0dab8f..fc11d6e482 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Fix using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434 - Fix issue with using dynamic import of module in uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/6434 - Fix build error where JSX v4 transformation of the discouraged forwardRef in uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/6447 +- Fix printing of exotic JSX names https://github.com/rescript-lang/rescript-compiler/pull/6451 #### :nail_care: Polish diff --git a/jscomp/syntax/src/res_printer.ml b/jscomp/syntax/src/res_printer.ml index f85094a7c7..5921ed50a9 100644 --- a/jscomp/syntax/src/res_printer.ml +++ b/jscomp/syntax/src/res_printer.ml @@ -4354,19 +4354,19 @@ and printJsxProp ~state arg cmtTbl = * Navabar.createElement -> Navbar * Staff.Users.createElement -> Staff.Users *) and printJsxName {txt = lident} = + let printIdent = printIdentLike ~allowUident:true in let rec flatten acc lident = match lident with - | Longident.Lident txt -> txt :: acc - | Ldot (lident, txt) -> - let acc = if txt = "createElement" then acc else txt :: acc in - flatten acc lident + | Longident.Lident txt -> printIdent txt :: acc + | Ldot (lident, "createElement") -> flatten acc lident + | Ldot (lident, txt) -> flatten (printIdent txt :: acc) lident | _ -> acc in match lident with - | Longident.Lident txt -> Doc.text txt + | Longident.Lident txt -> printIdent txt | _ as lident -> let segments = flatten [] lident in - Doc.join ~sep:Doc.dot (List.map Doc.text segments) + Doc.join ~sep:Doc.dot segments and printArgumentsWithCallbackInFirstPosition ~dotted ~state args cmtTbl = (* Because the same subtree gets printed twice, we need to copy the cmtTbl. diff --git a/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt b/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt index 35f7b9ef58..1234bb6ecd 100644 --- a/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/jsx.res.txt @@ -4,6 +4,8 @@ let x = let x = let x = let x = +let x = <\"custom-tag" className="container" /> +let x = // https://github.com/rescript-lang/syntax/issues/570 let x = @@ -35,6 +37,16 @@ let x = {a} {b} +let x = + <\"custom-tag" className="container"> + {a} + + +let x = + + {a} + + let x =
diff --git a/jscomp/syntax/tests/printer/expr/jsx.res b/jscomp/syntax/tests/printer/expr/jsx.res index 074d89769f..e44a26cd1f 100644 --- a/jscomp/syntax/tests/printer/expr/jsx.res +++ b/jscomp/syntax/tests/printer/expr/jsx.res @@ -6,6 +6,8 @@ let x = let x = +let x = <\"custom-tag" className="container" /> +let x = // https://github.com/rescript-lang/syntax/issues/570 let x = @@ -13,6 +15,8 @@ let x = {children} let x = {children} let x = {a} let x = {a} {b} +let x = <\"custom-tag" className="container" > {a} +let x = {a} let x =