]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(slots): should update compiled dynamic slots
authorEvan You <yyx990803@gmail.com>
Wed, 8 Apr 2020 16:23:44 +0000 (12:23 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 8 Apr 2020 16:23:44 +0000 (12:23 -0400)
packages/runtime-core/src/componentSlots.ts

index dbc01848d7f162251e2cde878a57914167c9c99b..e3c23f882a1968061cb8ef1423a7defcdce0ecd9 100644 (file)
@@ -123,13 +123,18 @@ export const updateSlots = (
   let deletionComparisonTarget = EMPTY_OBJ
   if (vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
     if ((children as RawSlots)._ === 1) {
-      if (!(vnode.patchFlag & PatchFlags.DYNAMIC_SLOTS)) {
-        // compiled AND static. this means we can skip removal of potential
-        // stale slots
+      // compiled slots.
+      if (
+        // bail on dynamic slots (v-if, v-for, reference of scope variables)
+        !(vnode.patchFlag & PatchFlags.DYNAMIC_SLOTS) &&
+        // bail on HRM updates
+        !(__DEV__ && instance.parent && instance.parent.renderUpdated)
+      ) {
+        // compiled AND static.
+        // no need to update, and skip stale slots removal.
         needDeletionCheck = false
-      }
-      // HMR force update
-      if (__DEV__ && instance.parent && instance.parent.renderUpdated) {
+      } else {
+        // compiled but dynamic - update slots, but skip normalization.
         extend(slots, children as Slots)
       }
     } else {