fix(slots): should update compiled dynamic slots

This commit is contained in:
Evan You 2020-04-08 12:23:44 -04:00
parent da6e64831a
commit 84440780f9

View 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 {