Re: [w3ctag/design-reviews] FYI - Add optional `submitter` parameter to the `FormData` constructor (Issue #812)

Ooh that's a great point @LeaVerou!

There were discussions around this before I got involved, and the consensus was to add a [second optional argument](https://github.com/whatwg/xhr/issues/262#issuecomment-548720848), @annevk might be able to add some more context around those conversations.

I probably should have provided a better example, as it's a little clearer and more ergonomic for the the primary use case. Typically this would be used after a user clicks on a submit button, e.g. something like:

```javascript
myform.addEventListener("submit", e => {
  e.preventDefault();
  const formData = new FormData(e.target, e.submitter);
  // do a fetch or something
});
```

or 

```javascript
mybutton.addEventListener("click", e => {
  e.preventDefault();
  const formData = new FormData(e.form, e.target);
  // do a fetch or something
});
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/812#issuecomment-1409530665
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/812/1409530665@github.com>

Received on Monday, 30 January 2023 23:46:03 UTC