Safari 11.1 formData() bug

Yesterday I encountered a weird bug in Safari 11. Using formData() and an empty input=file caused an error when posting a form via AJAX. Nothing happened, and nothing got submitted. It seems like there is a bug in Safari 11 (and maybe on iOS?) using empty file uploaded.

My workaround was not to add any empty input=file when submitting the form. So far this solution seems to work:

for (i = 0; i < form.elements.length; i++) {
    if (form.elements[i].type == 'file') {
        if (form.elements[i].value == '') {
            continue;
        }
    }
    form.append(form.elements[i].name, form.elements[i].value)
}