Skip to content
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

Allow data-* attributes #93

Open
davesnx opened this issue Dec 29, 2021 · 2 comments
Open

Allow data-* attributes #93

davesnx opened this issue Dec 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@davesnx
Copy link
Member

davesnx commented Dec 29, 2021

Currently, there's no way to pass data-* into an element, while React allows it. There's currently a workaround where avoiding JSX transformations you can pass an object with the key being data-watever.

This makes it a little hard to create components that might rely on external from your react code, such as Analytics, error reporting and integration with older frontend systems.

The idea is to have a special case where data_what or dataWhat (or literally whatever we want, didn't think deeply about any edge case) gets transformed into data-what as an attribute on the DOM element.

@jchavarri
Copy link
Collaborator

@davesnx Do you think it is enough with the approach suggested in #111 (comment)?

I think trying to do something more sophisticated at library or ppx might be too hard to maintain (when compared to the benefits), and the DX of calling createDOMElementVariadic is not that bad.

@davesnx
Copy link
Member Author

davesnx commented Jan 19, 2022

Right, the approach I'm proposing seems too magic compared with createDOMElementVariadic. But I don't see the solution to attributes called (data-) that need to be attached to dom elements. In JSX (React 16) you can attach any data- prop into any component and will be placed in the DOM as an attribute.

This issue aims to reflect the same behaviour as JSX but adds a few constraints since we can't use - for labelled arguments. I assume we wanted to make it work for all components but maybe that isn't the case.

I proposed to use lower_case as data_*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants