From 58e2d71f449f81e0f543f16c598246e4c9d6357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=83=B3?= <32740073+GRPdream@users.noreply.github.com> Date: Thu, 12 Jan 2023 11:16:11 +0800 Subject: [PATCH] fix(runtime-core): pruneCacheEntry rectify the judgment logic (fix #7355) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keep-alive component status abnormal when cache items more than its max, after debugging, I found that its judge 2 VNode is same logic is wrong(as cached.type !== current.type). Author: 李想 <945452469@qq.com> --- packages/runtime-core/src/components/KeepAlive.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index 554b9f2451c..cd556d686bd 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -13,7 +13,8 @@ import { cloneVNode, isVNode, VNodeProps, - invokeVNodeHook + invokeVNodeHook, + isSameVNodeType } from '../vnode' import { warn } from '../warning' import { @@ -193,7 +194,7 @@ const KeepAliveImpl: ComponentOptions = { function pruneCacheEntry(key: CacheKey) { const cached = cache.get(key) as VNode - if (!current || cached.type !== current.type) { + if (!current || !isSameVNodeType(cached, current)) { unmount(cached) } else if (current) { // current active instance should no longer be kept-alive.