Просмотр исходного кода

avoid resetting innerHTML/textContent if value is the same (fix #4247)

Evan You 9 лет назад
Родитель
Сommit
e4fd632790
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      src/platforms/web/runtime/modules/dom-props.js

+ 4 - 3
src/platforms/web/runtime/modules/dom-props.js

@@ -21,13 +21,14 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
     }
   }
   for (key in props) {
+    cur = props[key]
     // ignore children if the node has textContent or innerHTML,
     // as these will throw away existing DOM nodes and cause removal errors
     // on subsequent patches (#3360)
-    if ((key === 'textContent' || key === 'innerHTML') && vnode.children) {
-      vnode.children.length = 0
+    if (key === 'textContent' || key === 'innerHTML') {
+      if (vnode.children) vnode.children.length = 0
+      if (cur === oldProps[key]) continue
     }
-    cur = props[key]
     if (key === 'value') {
       // store value as _value as well since
       // non-string values will be stringified