Skip to content

Add the missing loc of jsx call expression #5960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions res_syntax/src/reactjs_jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,25 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
( Exp.ident {loc = Location.none; txt = Ldot (Lident "React", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
([(nolabel, makeID); (nolabel, props)] @ keyAndUnit)
| _ -> (
match (!childrenArg, keyProp) with
| None, key :: _ ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "JsxPPXReactSupport", "createElementWithKey");
})
[key; (nolabel, makeID); (nolabel, props)]
| None, [] ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{loc = Location.none; txt = Ldot (Lident "React", "createElement")})
[(nolabel, makeID); (nolabel, props)]
| Some children, key :: _ ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
Expand All @@ -463,7 +464,7 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
})
[key; (nolabel, makeID); (nolabel, props); (nolabel, children)]
| Some children, [] ->
Exp.apply ~attrs
Exp.apply ~loc:jsxExprLoc ~attrs
(Exp.ident
{
loc = Location.none;
Expand Down Expand Up @@ -544,7 +545,7 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
( Exp.ident {loc = Location.none; txt = Ldot (Lident "ReactDOM", "jsxs")},
[] )
in
Exp.apply ~attrs jsxExpr
Exp.apply ~loc:jsxExprLoc ~attrs jsxExpr
([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit)
| _ ->
let children, nonChildrenProps =
Expand Down
2 changes: 2 additions & 0 deletions res_syntax/tests/ppx/react/expected/forwardRef.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ module V4A = {
@react.component
let make = (_: props) => {
let input = React.useRef(Js.Nullable.null)

ReactDOM.jsx(
"div",
{
Expand Down Expand Up @@ -279,6 +280,7 @@ module V4AUncurried = {
@react.component
let make = (_: props) => {
let input = React.useRef(Js.Nullable.null)

ReactDOM.jsx(
"div",
{
Expand Down