Re: [whatwg/xhr] FormData: Add ability to specify submitter in addition to <form> (#262)

> Context: [whatwg/html#3195](https://github.com/whatwg/html/issues/3195) Context: #202
> 
> FormData should have ability to add an entry for a submitter button when it appends entries for a <form>.
> 
> We have multiple options of how to specify submitter. See five comments since [whatwg/html#3195 (comment)](https://github.com/whatwg/html/issues/3195#issuecomment-540927844)
> 
> A) `constructor(optional (HTMLFormElement or record<USVString, FormDataEntryValue>) formOrMap, optional HTMLElement? submitter = null)` Idiomatic.
> 
> B) `constructor(optional (HTMLElement or record<...>) formOrSubmitterOrMap)` `HTMLElement` represents a form or a submitter.
> 
> C) `constructor(optional (HTMLFormElement or FormDataInit) formOrDict)`
> 
> ```
> dictionary FormDataInit {
>  HTMLFormElement form;
>  HTMLElement? submitter;
>  record<...> map;
> }
> ```
> 
> The content of the dictionary is idiomatic. Need to wrap a record with a dictionary. Extensible. It's easy to add new members to the dictionary in the future.
> 
> D) `constructor(optional (HTMLFormElement or FormDataInit or URLSearchParams) init)`
> 
> ```
> dictionary FormDataInit {
>   required HTMLFormElement form;
>   HTMLElement? submitter = null;
> }
> ```
> 
> `FormData` doesn't support `record<>` directly. Developers have to write `new FormData(new URLSearchParams(map))`.
> 
> E) `constructor(optional HTMLFormElement form, optional HTMLElement? submitter = null)` `FormData append(record<USVString, FormDataEntryValue> map);` Developers have to write `new FormData().append(map)`.
> 
> F) (no changes on the constructor)
> 
> ```
> FormData append(HTMLFormElement form, optional HTMLElement? submitter = null);
> FormData append(record<USVString, FormDataEntryValue> map);
> ```
> 
> Developers have to write `let fd = new FormData().append(form, submitter);` if they want to collect entries including an entry for the submitter.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/issues/262#issuecomment-1057075327
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/xhr/issues/262/1057075327@github.com>

Received on Wednesday, 2 March 2022 15:45:09 UTC