Skip to content

Commit

Permalink
Add submitter parameter to FormData constructor (#9145)
Browse files Browse the repository at this point in the history
Summary:
This has been widely available for a [while](https://caniuse.com/?search=FormData.submitter) now

References:
- https://xhr.spec.whatwg.org/#interface-formdata
- https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData
- whatwg/xhr#366 (review) (discussion on why null is allowed)

Pull Request resolved: #9145

Reviewed By: SamChou19815

Differential Revision: D57181660

fbshipit-source-id: 98502daf0a26d361820739a90607e7a2d1275d66
  • Loading branch information
jenseng authored and facebook-github-bot committed May 10, 2024
1 parent d8e227c commit 2bcee69
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 152 deletions.
2 changes: 1 addition & 1 deletion lib/bom.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ declare class DOMParser {
type FormDataEntryValue = string | File
declare class FormData {
constructor(form?: HTMLFormElement): void;
constructor(form?: HTMLFormElement, submitter?: HTMLElement | null): void;
has(name: string): boolean;
get(name: string): ?FormDataEntryValue;
Expand Down
3 changes: 3 additions & 0 deletions tests/bom/FormData.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const a: FormData = new FormData(); // correct
new FormData(''); // incorrect
new FormData(document.createElement('input')); // incorrect
new FormData(document.createElement('form')); // correct
new FormData(document.createElement('form'), null); // correct
new FormData(document.createElement('form'), document.createElement("button")); // correct
new FormData(document.createElement('form'), "submitter"); // incorrect

// has
const b: boolean = a.has('foo'); // correct
Expand Down

0 comments on commit 2bcee69

Please sign in to comment.