diff --git a/s3file/static/s3file/js/s3file.js b/s3file/static/s3file/js/s3file.js index a54917c..2a6a8bb 100644 --- a/s3file/static/s3file/js/s3file.js +++ b/s3file/static/s3file/js/s3file.js @@ -217,15 +217,17 @@ export class S3FileInput extends globalThis.HTMLElement { async submitHandler(event) { event.preventDefault() this.form?.dispatchEvent(new window.CustomEvent("upload")) - await Promise.all(this.form?.pendingRquests) + await Promise.all(this.form?.pendingRequests || []) this.form?.requestSubmit(event.submitter) } uploadHandler() { if (this.files.length && !this.upload) { this.upload = this.uploadFiles() - this.form.pendingRquests = this.form?.pendingRquests || [] - this.form.pendingRquests.push(this.upload) + if (this.form) { + this.form.pendingRequests = this.form.pendingRequests || [] + this.form.pendingRequests.push(this.upload) + } } } diff --git a/tests/__tests__/s3file.test.js b/tests/__tests__/s3file.test.js index d63d794..dcbd294 100644 --- a/tests/__tests__/s3file.test.js +++ b/tests/__tests__/s3file.test.js @@ -82,7 +82,7 @@ describe("S3FileInput", () => { input.uploadHandler() console.log(input.upload) assert(input.upload) - assert(form.pendingRquests) + assert(form.pendingRequests) }) test("fromDataHandler", () => {