camlistored/ui: connect temp form to DOM before submitting

The download action of the web UI uses an ephemeral form, that we do not
connect to the DOM, behind the scenes. However, according to
https://html.spec.whatwg.org/multipage/forms.html#form-submission-algorithm,
step 2., a form must be connected to the DOM in order for it to be
submitted.

This change connects the form right before submitting, and removes it
from the DOM right after submission.

Fixes #921

Change-Id: I4d993c633c60a369ce4260f84731a64e8b955c76
This commit is contained in:
mpl 2017-04-26 17:44:50 +02:00
parent 8a545a1ed2
commit dace68256b
1 changed files with 6 additions and 0 deletions

View File

@ -144,6 +144,12 @@ func (d *DownloadItemsBtnDef) downloadSelection() error {
form.Action = downloadPrefix
form.Method = "POST"
form.AppendChild(input)
// As per
// https://html.spec.whatwg.org/multipage/forms.html#form-submission-algorithm
// step 2., a form must be connected to the DOM for submission.
body := dom.GetWindow().Document().QuerySelector("body")
body.AppendChild(form)
defer body.RemoveChild(form)
form.Submit()
return nil
}