react
react copied to clipboard
Use `FormData` `submitter` parameter
Summary
Fixes #29018
Rather than continuing to maintain/fix a partial polyfill (e.g. #28056), just pass the submitter
to the FormData
constructor, since it is now widely available. This ensures that the form data is populated consistently with a native form submission, and lets us remove a whole lot of code. This is a followup to this discussion over a year ago: https://github.com/facebook/react/pull/26674/files/5a7629ddb4f22072e37ba1ae581977ce03bdf288#r1178495317
Elaborating on that, if we're concerned about browsers that don't support it, it's important to note that:
- Many of them also don't support
SubmitEvent.submitter
, which means the existing approach won't work for them either - The
FormData
submitter
can easily be polyfilled (as canSubmitEvent.submitter
) for developers that care about named submit buttons working correctly in old browsers
How did you test this change?
Updated an existing test to more fully cover submitter
serialization, and ran yarn test
and yarn test --prod
successfully.