fix(select): emit-option with normalized option

This commit is contained in:
07akioni 2019-12-26 14:54:06 +08:00
parent 8963a9a61f
commit 6ce780ae7b

View File

@ -353,6 +353,14 @@ export default {
return option.value === this.value return option.value === this.value
} }
}, },
normalizeOption (option) {
const normalizedOption = {
label: option.label,
value: option.value,
disabled: option.disabled
}
return normalizedOption
},
/** /**
* event utils methods * event utils methods
*/ */
@ -363,11 +371,11 @@ export default {
this.$emit('change', null) this.$emit('change', null)
} else { } else {
let options = this.mapValuesToOptions(newValue) let options = this.mapValuesToOptions(newValue)
this.$emit('change', options) this.$emit('change', options.map(this.normalizeOption))
} }
} else { } else {
const option = this.getOption(newValue) const option = this.getOption(newValue)
this.$emit('change', option) this.$emit('change', this.normalizeOption(option))
} }
} else { } else {
this.$emit('change', newValue) this.$emit('change', newValue)