|
@@ -2,6 +2,7 @@ import {
|
|
|
type ComponentInternalInstance,
|
|
type ComponentInternalInstance,
|
|
|
type ComponentOptions,
|
|
type ComponentOptions,
|
|
|
type ConcreteComponent,
|
|
type ConcreteComponent,
|
|
|
|
|
+ type GenericComponentInstance,
|
|
|
type SetupContext,
|
|
type SetupContext,
|
|
|
getComponentName,
|
|
getComponentName,
|
|
|
getCurrentInstance,
|
|
getCurrentInstance,
|
|
@@ -436,7 +437,7 @@ function registerKeepAliveHook(
|
|
|
hook.__wdc ||
|
|
hook.__wdc ||
|
|
|
(hook.__wdc = () => {
|
|
(hook.__wdc = () => {
|
|
|
// only fire the hook if the target instance is NOT in a deactivated branch.
|
|
// only fire the hook if the target instance is NOT in a deactivated branch.
|
|
|
- let current: ComponentInternalInstance | null = target
|
|
|
|
|
|
|
+ let current: GenericComponentInstance | null = target
|
|
|
while (current) {
|
|
while (current) {
|
|
|
if (current.isDeactivated) {
|
|
if (current.isDeactivated) {
|
|
|
return
|
|
return
|
|
@@ -453,7 +454,7 @@ function registerKeepAliveHook(
|
|
|
// arrays.
|
|
// arrays.
|
|
|
if (target) {
|
|
if (target) {
|
|
|
let current = target.parent
|
|
let current = target.parent
|
|
|
- while (current && current.parent) {
|
|
|
|
|
|
|
+ while (current && current.parent && current.parent.vnode) {
|
|
|
if (isKeepAlive(current.parent.vnode)) {
|
|
if (isKeepAlive(current.parent.vnode)) {
|
|
|
injectToKeepAliveRoot(wrappedHook, type, target, current)
|
|
injectToKeepAliveRoot(wrappedHook, type, target, current)
|
|
|
}
|
|
}
|
|
@@ -466,7 +467,7 @@ function injectToKeepAliveRoot(
|
|
|
hook: Function & { __weh?: Function },
|
|
hook: Function & { __weh?: Function },
|
|
|
type: LifecycleHooks,
|
|
type: LifecycleHooks,
|
|
|
target: ComponentInternalInstance,
|
|
target: ComponentInternalInstance,
|
|
|
- keepAliveRoot: ComponentInternalInstance,
|
|
|
|
|
|
|
+ keepAliveRoot: GenericComponentInstance,
|
|
|
) {
|
|
) {
|
|
|
// injectHook wraps the original for error handling, so make sure to remove
|
|
// injectHook wraps the original for error handling, so make sure to remove
|
|
|
// the wrapped version.
|
|
// the wrapped version.
|