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 let deletionComparisonTarget = EMPTY_OBJ
if (vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) { if (vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
if ((children as RawSlots)._ === 1) { if ((children as RawSlots)._ === 1) {
if (!(vnode.patchFlag & PatchFlags.DYNAMIC_SLOTS)) { // compiled slots.
// compiled AND static. this means we can skip removal of potential if (
// stale slots // 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 needDeletionCheck = false
} } else {
// HMR force update // compiled but dynamic - update slots, but skip normalization.
if (__DEV__ && instance.parent && instance.parent.renderUpdated) {
extend(slots, children as Slots) extend(slots, children as Slots)
} }
} else { } else {