|
@@ -1713,6 +1713,7 @@ function baseCreateRenderer(
|
|
|
) => {
|
|
) => {
|
|
|
const { props, ref, children, dynamicChildren, shapeFlag, dirs } = vnode
|
|
const { props, ref, children, dynamicChildren, shapeFlag, dirs } = vnode
|
|
|
const shouldInvokeDirs = shapeFlag & ShapeFlags.ELEMENT && dirs
|
|
const shouldInvokeDirs = shapeFlag & ShapeFlags.ELEMENT && dirs
|
|
|
|
|
+ const shouldKeepAlive = shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE
|
|
|
let vnodeHook: VNodeHook | undefined | null
|
|
let vnodeHook: VNodeHook | undefined | null
|
|
|
|
|
|
|
|
// unset ref
|
|
// unset ref
|
|
@@ -1720,12 +1721,12 @@ function baseCreateRenderer(
|
|
|
setRef(ref, null, parentComponent, null)
|
|
setRef(ref, null, parentComponent, null)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ((vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
|
|
|
|
|
|
+ if ((vnodeHook = props && props.onVnodeBeforeUnmount) && !shouldKeepAlive) {
|
|
|
invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
|
invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (shapeFlag & ShapeFlags.COMPONENT) {
|
|
if (shapeFlag & ShapeFlags.COMPONENT) {
|
|
|
- if (shapeFlag & ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE) {
|
|
|
|
|
|
|
+ if (shouldKeepAlive) {
|
|
|
;(parentComponent!.ctx as KeepAliveContext).deactivate(vnode)
|
|
;(parentComponent!.ctx as KeepAliveContext).deactivate(vnode)
|
|
|
} else {
|
|
} else {
|
|
|
unmountComponent(vnode.component!, parentSuspense, doRemove)
|
|
unmountComponent(vnode.component!, parentSuspense, doRemove)
|
|
@@ -1757,7 +1758,10 @@ function baseCreateRenderer(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) &&
|
|
|
|
|
+ !shouldKeepAlive
|
|
|
|
|
+ ) {
|
|
|
queuePostRenderEffect(() => {
|
|
queuePostRenderEffect(() => {
|
|
|
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
|
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode)
|
|
|
shouldInvokeDirs &&
|
|
shouldInvokeDirs &&
|