Skip to content

Commit

Permalink
Respect data-val-event for select
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Oct 17, 2023
1 parent 7fe1de0 commit 1f8abdf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,13 @@ export class ValidationService {
}, this.debounce);
};

let isDropdown = input.tagName.toLowerCase() === 'select';
let validateEvent = input.dataset.valEvent;
if (isDropdown) {
input.addEventListener('change', cb);
} else if (validateEvent) {
if (validateEvent) {
input.addEventListener(validateEvent, cb);
}
else {
input.addEventListener('input', cb);
let eventType = input instanceof HTMLSelectElement ? 'change' : 'input';
input.addEventListener(eventType, cb);
}

this.inputEvents[uid] = cb;
Expand Down

0 comments on commit 1f8abdf

Please sign in to comment.