From 08fc888515392560d5c55fab22c0b79161fc3713 Mon Sep 17 00:00:00 2001 From: raivaibhav Date: Sat, 23 Oct 2021 01:42:53 +0530 Subject: [PATCH] check by count --- src/runtime/internal/dom.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 4aafcc0467..4e88882ac2 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -534,17 +534,17 @@ export function set_style(node, key, value, important) { } export function select_option(select, value) { - let have_select_attr = false; + let count_selected_attr = 0; for (let i = 0; i < select.options.length; i += 1) { const option = select.options[i]; - if (option.hasAttribute('selected')) have_select_attr = true; + if (option.hasAttribute('selected')) count_selected_attr++; if (option.__value === value) { option.selected = true; return; } } - if (!have_select_attr) select.selectedIndex = -1; // no option should be selected + if (count_selected_attr === 0) select.selectedIndex = -1; // no option should be selected } export function select_options(select, value) {