fix(runtime-dom/v-model): only set selectedIndex when the value changes (#3845)

This commit is contained in:
HcySunYang 2021-05-30 08:42:13 +08:00 committed by GitHub
parent 8b94464a3b
commit ecd97ee6e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,12 +224,12 @@ function setSelected(el: HTMLSelectElement, value: any) {
}
} else {
if (looseEqual(getValue(option), value)) {
el.selectedIndex = i
if (el.selectedIndex !== i) el.selectedIndex = i
return
}
}
}
if (!isMultiple) {
if (!isMultiple && el.selectedIndex !== -1) {
el.selectedIndex = -1
}
}