]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): handle component updates with only class/style bindings
authorEvan You <yyx990803@gmail.com>
Thu, 13 Feb 2020 22:27:52 +0000 (17:27 -0500)
committerEvan You <yyx990803@gmail.com>
Thu, 13 Feb 2020 22:27:52 +0000 (17:27 -0500)
packages/runtime-core/src/componentRenderUtils.ts

index 5e60ad397528e79315d2ec5ea5edfae2f08daf26..a105ce987f5ab9c20404cb457171ede287ed65e4 100644 (file)
@@ -172,12 +172,20 @@ export function shouldUpdateComponent(
     if (patchFlag & PatchFlags.FULL_PROPS) {
       // presence of this flag indicates props are always non-null
       return hasPropsChanged(prevProps!, nextProps!)
-    } else if (patchFlag & PatchFlags.PROPS) {
-      const dynamicProps = nextVNode.dynamicProps!
-      for (let i = 0; i < dynamicProps.length; i++) {
-        const key = dynamicProps[i]
-        if (nextProps![key] !== prevProps![key]) {
-          return true
+    } else {
+      if (patchFlag & PatchFlags.CLASS) {
+        return prevProps!.class === nextProps!.class
+      }
+      if (patchFlag & PatchFlags.STYLE) {
+        return hasPropsChanged(prevProps!.style, nextProps!.style)
+      }
+      if (patchFlag & PatchFlags.PROPS) {
+        const dynamicProps = nextVNode.dynamicProps!
+        for (let i = 0; i < dynamicProps.length; i++) {
+          const key = dynamicProps[i]
+          if (nextProps![key] !== prevProps![key]) {
+            return true
+          }
         }
       }
     }