Ensure FormDataPolyfill arg is optional (#749)

Fixes #747
This commit is contained in:
Jared White
2022-05-11 05:08:53 -07:00
committed by GitHub
parent 4a0f6ef8af
commit d683a76a49

View File

@@ -26,13 +26,21 @@ class FormDataEventPolyfill extends Event {
class FormDataPolyfill extends FormData {
private form: HTMLFormElement;
constructor(form: HTMLFormElement) {
super(form);
this.form = form;
form.dispatchEvent(new FormDataEventPolyfill(this));
constructor(form?: HTMLFormElement | null) {
if (form) {
super(form);
this.form = form
form.dispatchEvent(new FormDataEventPolyfill(this));
} else {
super();
}
}
append(name: string, value: any) {
if (!this.form) {
return super.append(name, value)
}
let input = this.form.elements[name as any] as HTMLInputElement;
if (!input) {