Skip to content

Support data-* attributes in DOM JSX - #933

Draft
anmonteiro wants to merge 4 commits into
mainfrom
anmonteiro/proposal-data-attrs
Draft

anmonteiro wants to merge 4 commits into
mainfrom
anmonteiro/proposal-data-attrs

Conversation

@anmonteiro

@anmonteiro anmonteiro commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Support arbitrary string-valued data attributes in DOM JSX, including optional attributes. Builds on #934 and #935, adapting their baseline tests to exercise JSX support. Fixes #230; related to melange-re/melange#2004.

01a17001-efda-7320-8b10-3844e629533f

@davesnx

davesnx commented Sep 28, 2026

Copy link
Copy Markdown
Member

Note on digits: server-reason-react's ppx converts data attribute names differently when a digit follows a letter.

JSX name this PR server-reason-react
dataVersion2 data-version2 data-version-2

server-reason-react puts a dash before every character that is unchanged by Char.uppercase_ascii, and digits are unchanged, so each digit gets a dash. This PR puts a dash only before A–Z.

If one component is rendered on the server with server-reason-react and hydrated with reason-react, the attribute names will not match. We should agree on one rule. data-version2 looks like the better choice to me (it matches how dataset maps data-version2 to version2), so we can change server-reason-react to match this PR.

@anmonteiro
anmonteiro force-pushed the anmonteiro/proposal-data-attrs branch from 5d27b57 to 6f1ef6b Compare October 24, 2026 23:14
@anmonteiro anmonteiro changed the title proposal: support data-* attributes in DOM JSX Support data-* attributes in DOM JSX Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow data-* in DOM elements

2 participants