Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: React Handles Native Attributes Incorrectly for Custom Elements, Causing Runtime Errors | GoodFirstPicks

Bug: React Handles Native Attributes Incorrectly for Custom Elements, Causing Runtime Errors

facebook/react 3 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeReactJavaScriptTypeScript

Why this is a good first issue

Custom element attribute handling differs from native elements causing runtime errors.

AI Summary

The issue reports inconsistent attribute handling between native elements and custom elements in React, specifically for 'form' and 'aria-invalid' attributes. The fix would require modifying React's attribute handling logic for custom elements to match native behavior. The main blocker is understanding React's internal attribute processing logic and potential impacts on custom element support.

Issue Description

The common/global HTML attributes are treated differently between native elements and Custom Elements. For example, <input aria-invalid={true}> in React produces <input aria-invalid="true"> in the HTML. But <custom-element aria-invalid={true}> in React produces <custom-element aria-invalid> in the HTML. This leads to an inconsistent and bug-prone DX. In some cases, it also results in runtime errors.

Relates to: #32251

React Version: 19.1.1

Steps To Reproduce

For the form Attribute

  1. Create a form-associated Custom Element
  2. Define a form getter on it (similar to native form controls)
  3. In React, attempt to point the Custom Element's form attribute to a specific <form> element

For the aria-invalid Attribute

  1. Create a Custom Element
  2. In React, set the Custom Element's aria-invalid attribute to true

Example Reproduction: https://stackblitz.com/edit/react-custom-elements-global-attrs?file=src%2FApp.tsx,index.html&terminal=dev

The current behavior

For the form Attribute

An error is thrown at runtime, because React tries to set a getter instead of altering the form attribute (which is what happens for native form controls).

For the aria-invalid Attribute

The attribute is set to an empty string ("") as if it were a literal boolean attribute.

The expected behavior

For the form Attribute

An error should not be thrown, and React should not attempt to set a JS Property. Instead, React should treat the attribute the same way it does for native form controls, setting the attribute only.

For the aria-invalid Attribute

The attribute should be treated the same way as it is for other native elements: aria-invalid={true} should become aria-invalid="true" and aria-invalid={false} should become aria-invalid="false".

The overall expectation beyond these 2 things is that for any attribute in the set of "common/nati

GitHub Labels

Status: UnconfirmedResolution: Stale

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • custom elements
  • attribute handling
  • React internals
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno