Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Add the missing loc of jsx call expression (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki authored Jan 30, 2023
1 parent 08a18fe commit 380440e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- Fix parsing of spread props as an expression in JSX V4 https://github.com/rescript-lang/syntax/pull/721
- Fix dropping attributes from props in make function in JSX V4 https://github.com/rescript-lang/syntax/pull/723
- Fix an issue where error messages related to duplicate props were displayed without a loc and were unclear https://github.com/rescript-lang/syntax/pull/728
- Fix issue where error messages related to non-existent props were displayed without location information https://github.com/rescript-lang/syntax/pull/730

#### :eyeglasses: Spec Compliance

Expand Down
13 changes: 7 additions & 6 deletions cli/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
1 change: 1 addition & 0 deletions tests/ppx/react/expected/forwardRef.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ module V4A = {
@react.component
let make = (_: props) => {
let input = React.useRef(Js.Nullable.null)

ReactDOM.jsx(
"div",
{
Expand Down

0 comments on commit 380440e

Please sign in to comment.