test: tests for keep-alive

This commit is contained in:
Evan You
2019-10-30 21:41:28 -04:00
parent a42d165285
commit 5fcb81050a
6 changed files with 324 additions and 63 deletions

View File

@@ -863,6 +863,7 @@ export function createRenderer<
setupRenderEffect(
instance,
parentComponent,
parentSuspense,
initialVNode,
container,
@@ -877,6 +878,7 @@ export function createRenderer<
function setupRenderEffect(
instance: ComponentInternalInstance,
parentComponent: ComponentInternalInstance | null,
parentSuspense: HostSuspenseBoundary | null,
initialVNode: HostVNode,
container: HostElement,
@@ -898,6 +900,10 @@ export function createRenderer<
if (instance.m !== null) {
queuePostRenderEffect(instance.m, parentSuspense)
}
// activated hook for keep-alive roots.
if (instance.a !== null) {
queuePostRenderEffect(instance.a, parentSuspense)
}
mounted = true
} else {
// updateComponent
@@ -1450,7 +1456,7 @@ export function createRenderer<
parentSuspense: HostSuspenseBoundary | null,
doRemove?: boolean
) {
const { bum, effects, update, subTree, um } = instance
const { bum, effects, update, subTree, um, da, isDeactivated } = instance
// beforeUnmount hook
if (bum !== null) {
invokeHooks(bum)
@@ -1470,6 +1476,10 @@ export function createRenderer<
if (um !== null) {
queuePostRenderEffect(um, parentSuspense)
}
// deactivated hook
if (da !== null && !isDeactivated) {
queuePostRenderEffect(da, parentSuspense)
}
queuePostFlushCb(() => {
instance.isUnmounted = true
})