Jelajahi Sumber

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

close #10396
Evan You 2 tahun lalu
induk
melakukan
ff130c4702
1 mengubah file dengan 2 tambahan dan 1 penghapusan
  1. 2 1
      packages/runtime-dom/src/modules/props.ts

+ 2 - 1
packages/runtime-dom/src/modules/props.ts

@@ -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