[FIX] Incorrect babel jsx attribute generation with hyphenated names in getContent step#1218
Open
[FIX] Incorrect babel jsx attribute generation with hyphenated names in getContent step#1218
Conversation
There was a problem hiding this comment.
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
getContentoutput 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.
sbarrio
approved these changes
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)