refactor(hmr): simplify hmr force update check

This commit is contained in:
Evan You
2020-06-12 14:53:48 -04:00
parent 8f2a7489b7
commit e76ed4c269
6 changed files with 24 additions and 43 deletions

View File

@@ -18,7 +18,7 @@ import {
import { warn } from './warning'
import { isKeepAlive } from './components/KeepAlive'
import { withCtx } from './helpers/withRenderContext'
import { queuePostFlushCb } from './scheduler'
import { isHmrUpdating } from './hmr'
export type Slot = (...args: any[]) => VNode[]
@@ -125,14 +125,10 @@ export const updateSlots = (
if (vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
if ((children as RawSlots)._ === 1) {
// compiled slots.
if (__DEV__ && instance.parent && instance.parent.hmrUpdated) {
if (__DEV__ && isHmrUpdating) {
// Parent was HMR updated so slot content may have changed.
// force update slots and mark instance for hmr as well
extend(slots, children as Slots)
instance.hmrUpdated = true
queuePostFlushCb(() => {
instance.hmrUpdated = false
})
} else if (
// bail on dynamic slots (v-if, v-for, reference of scope variables)
!(vnode.patchFlag & PatchFlags.DYNAMIC_SLOTS)