Commit d9ff845f63632050909fe394184b2bdaf976c545
1 parent
2fb29fae
Emit input event in mounted if parsed value diffs
Showing
1 changed file
with
8 additions
and
5 deletions
Show diff stats
src/components/date-picker/picker.vue
| ... | ... | @@ -135,9 +135,6 @@ |
| 135 | 135 | }, |
| 136 | 136 | default: 'bottom-start' |
| 137 | 137 | }, |
| 138 | - options: { | |
| 139 | - type: Object | |
| 140 | - }, | |
| 141 | 138 | transfer: { |
| 142 | 139 | type: Boolean, |
| 143 | 140 | default: false |
| ... | ... | @@ -250,7 +247,7 @@ |
| 250 | 247 | typeof this.options.disabledDate === 'function' && |
| 251 | 248 | this.options.disabledDate; |
| 252 | 249 | const valueToTest = isArrayValue ? newDate : newDate[0]; |
| 253 | - const isDisabled = disabledDateFn && disabledDateFn(valueToTest) | |
| 250 | + const isDisabled = disabledDateFn && disabledDateFn(valueToTest); | |
| 254 | 251 | |
| 255 | 252 | if (newValue !== oldValue && !isDisabled) { |
| 256 | 253 | this.emitChange(); |
| ... | ... | @@ -375,10 +372,16 @@ |
| 375 | 372 | publicValue(now, before){ |
| 376 | 373 | const newValue = JSON.stringify(now); |
| 377 | 374 | const oldValue = JSON.stringify(before); |
| 378 | - if (newValue !== oldValue) this.$emit('input', now); // to update v-model | |
| 375 | + const shouldEmitInput = newValue !== oldValue || typeof now !== typeof before; | |
| 376 | + if (shouldEmitInput) this.$emit('input', now); // to update v-model | |
| 379 | 377 | }, |
| 380 | 378 | }, |
| 381 | 379 | mounted () { |
| 380 | + const initialValue = this.value; | |
| 381 | + const parsedValue = this.publicValue; | |
| 382 | + if (typeof initialValue !== typeof parsedValue || JSON.stringify(initialValue) !== JSON.stringify(parsedValue)){ | |
| 383 | + this.$emit('input', this.publicValue); // to update v-model | |
| 384 | + } | |
| 382 | 385 | if (this.open !== null) this.visible = this.open; |
| 383 | 386 | } |
| 384 | 387 | }; | ... | ... |