Fix form submission #129
Reference in New Issue
Block a user
Delete Branch "fix/forms"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes check for radio and checkbox inputs (#124) and GET form submission (#126)
@robinnorth Is there any reason not to build the querystring for both GET and POST in 1 step, and then depending on the method, append it to
locationor the body?@robinnorth Would this be considered a breaking change?
There was indeed a reason to build them separately to begin with, as I was updating the query string parameters for GET submissions, however I've had to abandon that and discard any previously-set ones in order to properly reflect the behaviour of unchecked checkbox inputs on form submission -- they should be omitted entirely from the query string, even if they had been checked previously.
So, I will refactor this as suggested.
Technically maybe, but as we don't document the
requestOptionsoption or its keys, so the implication could be that you shouldn't rely on it to have a certain shape. I'm not sure that it's actually very useful to haverequestOptionsbe a part ofthis.optionsanyway, as it's only intended to be set internally by the library. As #127 and #130 show, it just causes issues with manual invocation when it's not set. Perhaps it should be refactored tothis.requestOptions?Do we need a global
requestOptionsat all? Why don't we just pass it directly toloadUrl()?No, I don't think we do need it to be global -- it can just be a third parameter to
loadUrl(), afteroptions, and default to an empty object if not set.That would be simpler.
I don't think we need to pass
optionseither. When it's needed, it can be retrieved fromthis.options.Currently the history popstate handler relies on being able to pass a modified options object to
loadUrl, so I don't think we can easily drop that parameter.Good point. But if it's not passed in, we can default to
this.options.@BehindTheMath I have pushed a refactor commit for the query string building, but have left
requestOptionsas-is for now, as I intend to make a separate PR to make some changes around that. Would be good to merge this before submitting that too.Looks good, so you can squash and merge this.
After thinking more about
requestOptions, do we need it to be inthis.optionsso that it gets stored with the history?Thanks @BehindTheMath.
Yes, I came to the same conclusion as you about
requestOptionsafter stepping through the code, but am going to change it so thatlib/send-request.jshandlesrequestOptionsbeing empty without throwing an error.