From dace68256b87e3741c8890a22b544e6286d9f4d8 Mon Sep 17 00:00:00 2001 From: mpl Date: Wed, 26 Apr 2017 17:44:50 +0200 Subject: [PATCH] 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 --- server/camlistored/ui/goui/downloadbutton/downloadbutton.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/camlistored/ui/goui/downloadbutton/downloadbutton.go b/server/camlistored/ui/goui/downloadbutton/downloadbutton.go index 3f6cbb8a2..ec32f31ff 100644 --- a/server/camlistored/ui/goui/downloadbutton/downloadbutton.go +++ b/server/camlistored/ui/goui/downloadbutton/downloadbutton.go @@ -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 }