Skip to content

Commit

Permalink
Unwatch picker min/max when unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheyan committed Jul 16, 2020
1 parent bffc18a commit 84b2060
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/date-picker/src/picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ export default {
showClose: false,
userInput: null,
valueOnOpen: null, // value when picker opens, used to determine whether to emit change
unwatchPickerOptions: null
unwatchPickerOptions: null,
unwatchPickerMin: null,
unwatchPickerMax: null
};
},
Expand Down Expand Up @@ -846,12 +848,12 @@ export default {
this.picker.toggleAmPm = this.toggleAmPm || false;
this.picker.minimum = this.minimum || null;
this.$watch('minimum', (minimum) => {
this.unwatchPickerMin = this.$watch('minimum', (minimum) => {
this.picker.minimum = minimum || null;
});
this.picker.maximum = this.maximum || null;
this.$watch('maximum', (maximum) => {
this.unwatchPickerMax = this.$watch('maximum', (maximum) => {
this.picker.maximum = maximum || null;
});
Expand Down Expand Up @@ -916,6 +918,14 @@ export default {
if (typeof this.unwatchPickerOptions === 'function') {
this.unwatchPickerOptions();
}
if (typeof this.unwatchPickerMin === 'function') {
this.unwatchPickerMin();
this.unwatchPickerMin = null;
}
if (typeof this.unwatchPickerMax === 'function') {
this.unwatchPickerMax();
this.unwatchPickerMax = null;
}
this.picker.$el.parentNode.removeChild(this.picker.$el);
}
},
Expand Down

0 comments on commit 84b2060

Please sign in to comment.