Skip to content

Commit

Permalink
Move check for undefined inside handleValidated
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteracyFanatic committed Nov 1, 2023
1 parent ae4344a commit 2f2096e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 2f2096e

Please sign in to comment.