-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FYI - Add optional submitter
parameter to the FormData
constructor
#812
Comments
From an API design point of view, I find it odd that this was added as a positional argument and not a dictionary parameter. Seeing one of the examples in the wild, I'd have no idea what the second parameter is for, whereas See also: w3ctag/design-principles#366 (consensus on the principle, but I still need to write it) |
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, @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 primary use case. Typically this would be used after a user clicks on a submit button, e.g. something like: myform.addEventListener("submit", e => {
e.preventDefault();
const formData = new FormData(e.target, e.submitter);
// do a fetch or something
}); or mybutton.addEventListener("click", e => {
e.preventDefault();
const formData = new FormData(e.form, e.target);
// do a fetch or something
}); |
If we were to overload it would have to be the first argument (since |
Hi @jenseng – thanks for this and thanks for being receptive to my feedback. Just as a matter of process : we don’t really do FYIs. Either there’s something for us to review and feed back on or there isn’t. In this case, it seems like there very much is so we’ll treat this as we would any other review. Thanks! ✨ /cc @chrishtr
I respectfully disagree; I find |
Thanks for letting me know! I'll pass this along to the Chromium team, as I think they've done similar "FYI" reviews in the past 🙏
While In light of that, a mild concern I have around the dictionary approach is that developers could see it in the wild and misunderstand its purpose, trying to use it to specify arbitrary entries, e.g. |
The purpose of an FYI is to give the TAG notice that a change is happening that Chromium representatives think is simple and uncontroversial via other signals. But if you happen to notice design issues not already found, that is good and achieves one purpose of an FYI. The alternative would be not to send one at all, which fails to give you that opportunity. Upgrading this one to a regular TAG review if you think it's warranted is totally fine and makes sense. |
@plinss and I looked at this during a breakout today. Our thoughts were:
We do not see any architectural issues with adding the argument however, and do not have any other concerns beyond this API design issue, so we will go ahead and close this. |
Thank you. Perhaps the following was understood, but I wanted to explain the rationale some more just in case:
|
Wotcher TAG!
I'm requesting a TAG review of the optional
submitter
parameter to theFormData
constructor.Per the Chromium Intent to Ship, it was requested that I file a TAG review as a FYI - hence this request.
This new optional parameter allows developers to construct a
FormData
object that matches an equivalent native form submission, i.e. including the submit button entry(s), as appropriate.Further details:
We'd prefer the TAG provide feedback as:
💬 leave review feedback as a comment in this issue and @-notify @jenseng
The text was updated successfully, but these errors were encountered: