Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurk91 committed Oct 18, 2022
1 parent cc0efba commit f2cd3f1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Flatpickr from 'flatpickr';
import {excludedEvents, includedEvents} from './events.js';
import {arrayify, camelToKebab, nullify} from './util.js';
// You have to import css yourself
import {defineComponent, h, nextTick} from 'vue';
import {defineComponent, h} from 'vue';

// Keep a copy of all events for later use
const allEvents = includedEvents.concat(excludedEvents);
Expand All @@ -11,7 +10,7 @@ const allEvents = includedEvents.concat(excludedEvents);
const configCallbacks = ['locale', 'showMonths'];

export default defineComponent({
name: 'flat-pickr',
name: 'Flatpickr',
compatConfig: {
MODE: 3,
},
Expand Down Expand Up @@ -73,7 +72,9 @@ export default defineComponent({

// Immediate watch will fail before fp is set,
// so need to start watching after mount
this.$watch('disabled', this.watchDisabled, {immediate: true});
this.$watch('disabled', this.watchDisabled, {
immediate: true
});
},
methods: {
prepareConfig() {
Expand Down Expand Up @@ -118,7 +119,7 @@ export default defineComponent({
onInput(event) {
const input = event.target;
// Let's wait for DOM to be updated
nextTick().then(() => {
this.$nextTick(() => {
this.$emit('update:modelValue', nullify(input.value));
});
},
Expand Down Expand Up @@ -162,9 +163,7 @@ export default defineComponent({
config: {
deep: true,
handler(newConfig) {
if (!this.fp) {
return;
}
if (!this.fp) return;

let safeConfig = {...newConfig};
// Workaround: Don't pass hooks to configs again otherwise
Expand Down Expand Up @@ -199,7 +198,8 @@ export default defineComponent({
},
beforeUnmount() {
/* istanbul ignore else */
if (!this.fp) return
if (!this.fp) return;

this.fpInput().removeEventListener('blur', this.onBlur);
this.fp.destroy();
this.fp = null;
Expand Down

0 comments on commit f2cd3f1

Please sign in to comment.