fix(runtime-dom): avoid always resetting nullish option value

close #10396
This commit is contained in:
Evan You 2024-02-25 17:35:19 +08:00
parent 6bef15f094
commit ff130c4702
1 changed files with 2 additions and 1 deletions

View File

@ -39,7 +39,8 @@ export function patchDOMProp(
el._value = value
// #4956: <option> value will fallback to its text content so we need to
// compare against its attribute value instead.
const oldValue = tag === 'OPTION' ? el.getAttribute('value') : el.value
const oldValue =
tag === 'OPTION' ? el.getAttribute('value') || '' : el.value
const newValue = value == null ? '' : value
if (oldValue !== newValue) {
el.value = newValue