From 2f2096ef4cf00c0683e9249f52dfa9eef7d16da8 Mon Sep 17 00:00:00 2001 From: Jordan Cannon Date: Wed, 1 Nov 2023 16:45:56 -0500 Subject: [PATCH] Move check for undefined inside handleValidated --- src/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 36e30f7..f013c99 100644 --- a/src/index.ts +++ b/src/index.ts @@ -697,9 +697,11 @@ export class ValidationService { * @param success The validation result. * @param submitEvent The `SubmitEvent`. */ - handleValidated = (form: HTMLFormElement, success: boolean, submitEvent: SubmitEvent) => { + handleValidated = (form: HTMLFormElement, success: boolean, submitEvent?: SubmitEvent) => { if (success) { - this.submitValidForm(form, submitEvent); + if (submitEvent) { + this.submitValidForm(form, submitEvent); + } } else { this.focusFirstInvalid(form); @@ -860,9 +862,7 @@ export class ValidationService { // Firefox fix: redispatch 'submit' after finished handling this event await new Promise(resolve => setTimeout(resolve, 0)); - if (e) { - this.handleValidated(form, success, e); - } + this.handleValidated(form, success, e); }).catch(error => { this.logger.log('Validation error', error); }).finally(() => {