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

[core] feat: spread data-* props to HTML elements #4180

Merged
merged 2 commits into from
Jun 16, 2020
Merged

[core] feat: spread data-* props to HTML elements #4180

merged 2 commits into from
Jun 16, 2020

Conversation

justinbhopper
Copy link
Contributor

Fixes #3210

Checklist

  • Includes tests

Changes proposed in this pull request:

This PR changes removeNonHTMLProps so that it ignores any prop with hyphens. Typescript has a special rule to ignore hyphenated props (such as data-foo) during JSX attribute validation. It is not common to use hyphenated attributes for React props, as those props are not valid JS identifiers, so it is best to assume that any prop with a hyphen is intended for the rendered element.

https://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking

This will help in tests scenarios where data-attributes are used as test selectors.

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR, just a minor code style nit

packages/core/test/buttons/buttonTests.tsx Outdated Show resolved Hide resolved
Co-authored-by: Adi Dahiya <adi.dahiya14@gmail.com>
@adidahiya adidahiya changed the title Updated removeNonHTMLProps to ignore hyphenated props [core] feat: spread data-* props to HTML elements Jun 16, 2020
@adidahiya adidahiya merged commit cf31db7 into palantir:develop Jun 16, 2020
@justinbhopper justinbhopper deleted the allow-hyphen-props branch January 27, 2022 21:28
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.

data-* attributes being stripped from certain comopnents
2 participants