Skip to content

Skip redundant type and name writes for text inputs - #38231

Open
smg99 wants to merge 10 commits into
react:mainfrom
smg99:fix/react-dom-unchanged-text-input-attributes
Open

smg99 wants to merge 10 commits into
react:mainfrom
smg99:fix/react-dom-unchanged-text-input-attributes

Conversation

@smg99

@smg99 smg99 commented Nov 12, 2026

Copy link
Copy Markdown

Summary

React DOM clears and restores name and rewrites type when updating an input. This sequencing matters for radio groups. In a large form of named text inputs, it also causes three attribute mutations per input even when both attributes already match.

Skip these writes for ordinary inputs with an explicit type="text" and a matching string name. Keep value synchronization and the existing update order for radio inputs, mismatched attributes, customized inputs, and object values that can run code during coercion.

Adds a regression test that updates a controlled value and checks for zero name or type mutations. The test sees three mutations on unmodified main.

Addresses the named text input case in #36229. The broader approach in #36240 informed the scope of this change.

How did you test this change?

  • Ran the React DOM input, component, form, and event suites in development and production on both stable and experimental release channels. All 362 tests passed in each configuration.
  • Ran ESLint, Prettier, and git diff --check on the two changed files.
  • Compared production builds of cb7c59e and this patch in Chrome 157 on macOS. The benchmark synchronously re-renders the form and changes only the first controlled value. Each median covers 18 samples of 15 updates after warm-up.
Named text inputs Baseline median Patch median
500 0.20 ms 0.13 ms
5,000 1.98 ms 1.30 ms

The 5,000-input case went from 15,000 name and type writes to zero per update. Browser checks also covered uppercase radio types, customized input attribute callbacks, value coercion, and restoration of a changed name or type.

@meta-cla

meta-cla Bot commented Nov 12, 2026

Copy link
Copy Markdown

Hi @smg99!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

A size report will appear here when the build finishes.

Generated by sizebot against 3f80cf2

@meta-cla meta-cla Bot added the CLA Signed label Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant