Skip to content

Commit

Permalink
Refactor: blur event
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurk91 committed Jul 2, 2020
1 parent 8a5e434 commit 5bd1b6a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {arrayify, camelToKebab, cloneObject} from "./util.js";
// Keep a copy of all events for later use
const allEvents = includedEvents.concat(excludedEvents);

// Passing these properties in `set()` method will cause flatpickr to trigger some callbacks
// Passing these properties in `set()` method will cause flatpickr to trigger some internal callbacks
const configCallbacks = ['locale', 'showMonths'];

export default {
Expand All @@ -21,7 +21,8 @@ export default {
disabled: this.disabled
},
on: {
input: this.onInput
input: this.onInput,
blur: this.onBlur,
}
})
},
Expand Down Expand Up @@ -85,9 +86,6 @@ export default {
// Init flatpickr
this.fp = new Flatpickr(this.getElem(), safeConfig);

// Attach blur event
this.fpInput().addEventListener('blur', this.onBlur);

// Immediate watch will fail before fp is set,
// so need to start watching after mount
this.$watch('disabled', this.watchDisabled, {immediate: true})
Expand Down Expand Up @@ -191,7 +189,6 @@ export default {
beforeDestroy() {
/* istanbul ignore else */
if (this.fp) {
this.fpInput().removeEventListener('blur', this.onBlur);
this.fp.destroy();
this.fp = null;
}
Expand Down

0 comments on commit 5bd1b6a

Please sign in to comment.