jsx: className attr transform is applied to "uppercase components"
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 179
- Forks
- 63
- Avg merge
- 5h
- Merged PRs (30d)
- 22
Description
It seems JSX ppx renames className attribute to class for elements generated from uppercase components. This results in the createElement application being passed a ~class argument, which doesn't make sense as it's a reserved word.
To repro:
module Foo = {
let createElement = (~className, ()) => {
<div className />;
};
};
let el = <Foo className="bar" />
Error:
The function applied to this argument has type
(~className: Tyxml.Html.wrap(Html_types.nmtokens)) => Tyxml_html.elt([> Html_types.div ])
This argument cannot be applied with label ~class
Should attribute mangling only be applied to elements generated from lowercase components?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the JSX ppx transformation that handles className attributes and compare its behavior for lowercase elements versus uppercase components. Reproduce the example from the issue, then verify that the generated createElement call preserves the ~className label for the uppercase component case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100