Jelajahi Sumber

refactor: simplify conditions

Evan You 7 tahun lalu
induk
melakukan
cd3d202edb
1 mengubah file dengan 7 tambahan dan 9 penghapusan
  1. 7 9
      src/platforms/web/runtime/modules/dom-props.js

+ 7 - 9
src/platforms/web/runtime/modules/dom-props.js

@@ -38,14 +38,6 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
       }
     }
 
-    // skip the update if old and new VDOM state is the same.
-    // the only exception is `value` where the DOM value may be temporarily
-    // out of sync with VDOM state due to focus, composition and modifiers.
-    // This also covers #4521 by skipping the unnecesarry `checked` update.
-    if (key !== 'value' && cur === oldProps[key]) {
-      continue
-    }
-
     if (key === 'value') {
       // store value as _value as well since
       // non-string values will be stringified
@@ -66,7 +58,13 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
       while (svg.firstChild) {
         elm.appendChild(svg.firstChild)
       }
-    } else {
+    } else if (
+      // skip the update if old and new VDOM state is the same.
+      // `value` is handled separately because the DOM value may be temporarily
+      // out of sync with VDOM state due to focus, composition and modifiers.
+      // This  #4521 by skipping the unnecesarry `checked` update.
+      cur !== oldProps[key]
+    ) {
       elm[key] = cur
     }
   }