Skip to content

[FIX] [V2] Incorrect babel jsx attribute generation with hyphenated names in getContent step#1219

Open
cdn34dd wants to merge 1 commit intofeature/v2from
carlosnogueira/issue-1200/babel-fix-attributes-names-v2
Open

[FIX] [V2] Incorrect babel jsx attribute generation with hyphenated names in getContent step#1219
cdn34dd wants to merge 1 commit intofeature/v2from
carlosnogueira/issue-1200/babel-fix-attributes-names-v2

Conversation

@cdn34dd
Copy link
Contributor

@cdn34dd cdn34dd commented Mar 20, 2026

What does this PR do?

Ensure hyphenated JSX attribute names (e.g. aria-hidden, data-testid) are emitted as quoted string literals in the getContent output of the babel plugin, preventing Hermes runtime parse errors.

Motivation

Issue 1200

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

@cdn34dd cdn34dd requested a review from a team as a code owner March 20, 2026 16:36
Copilot AI review requested due to automatic review settings March 20, 2026 16:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes invalid JS generation in the React Native Babel plugin’s getContent output by ensuring JSX attributes with non-identifier names (notably hyphenated ones like aria-hidden, data-testid) are emitted as quoted string keys, avoiding Hermes parse errors.

Changes:

  • Update jsxChildToRuntimeCall to emit object property keys as identifiers only when the JSX attribute name is a valid JS identifier; otherwise emit a string literal key.
  • Add test coverage ensuring hyphenated attribute names are quoted in getContent, while valid identifier attribute names remain unquoted.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react-native-babel-plugin/src/actions/rum/index.ts Fixes getContent JSX-to-runtime conversion to quote invalid object keys (e.g., hyphenated JSX attribute names).
packages/react-native-babel-plugin/test/plugin.test.ts Adds regression tests validating quoted hyphenated keys in getContent and preserving unquoted valid keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

4 participants