[FIX] [V2] Incorrect babel jsx attribute generation with hyphenated names in getContent step#1219
Open
cdn34dd wants to merge 1 commit intofeature/v2from
Open
Conversation
There was a problem hiding this comment.
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
jsxChildToRuntimeCallto 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.
sbarrio
approved these changes
Mar 20, 2026
marco-saia-datadog
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)