From ecd97ee6e465ec5c841d58d96833fece4e899785 Mon Sep 17 00:00:00 2001 From: HcySunYang Date: Sun, 30 May 2021 08:42:13 +0800 Subject: [PATCH] fix(runtime-dom/v-model): only set selectedIndex when the value changes (#3845) --- packages/runtime-dom/src/directives/vModel.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/runtime-dom/src/directives/vModel.ts b/packages/runtime-dom/src/directives/vModel.ts index a90c4466..f63f909b 100644 --- a/packages/runtime-dom/src/directives/vModel.ts +++ b/packages/runtime-dom/src/directives/vModel.ts @@ -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 } }