Skip to content

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

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

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

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:30
Copilot AI review requested due to automatic review settings March 20, 2026 16:30
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 a Babel plugin codegen issue where JSX attributes with hyphens (e.g. aria-hidden, data-testid, bg-$backgroundDefault) were being emitted as bare identifiers inside the generated getContent function, producing invalid JS that can fail Hermes parsing.

Changes:

  • Emit JSX attribute keys as string literals when the attribute name is not a valid JS identifier (using t.isValidIdentifier).
  • Add Jest coverage to ensure hyphenated attribute names are quoted in getContent output and valid identifiers 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 Ensures JSX attribute keys generated for getContent use string literals when needed to avoid invalid JS.
packages/react-native-babel-plugin/test/plugin.test.ts Adds unit tests covering hyphenated attribute key quoting behavior in getContent.

💡 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.

3 participants