Skip to content

Commit 64af9ff

Browse files
authored
fix(runtime-core): pruneCacheEntry rectify the judgment logic (fix #7355)
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).
1 parent 4902354 commit 64af9ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/runtime-core/src/components/KeepAlive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
cloneVNode,
1414
isVNode,
1515
VNodeProps,
16-
invokeVNodeHook
16+
invokeVNodeHook,
17+
isSameVNodeType
1718
} from '../vnode'
1819
import { warn } from '../warning'
1920
import {
@@ -193,7 +194,7 @@ const KeepAliveImpl: ComponentOptions = {
193194

194195
function pruneCacheEntry(key: CacheKey) {
195196
const cached = cache.get(key) as VNode
196-
if (!current || cached.type !== current.type) {
197+
if (!current || !isSameVNodeType(cached, current)) {
197198
unmount(cached)
198199
} else if (current) {
199200
// current active instance should no longer be kept-alive.

0 commit comments

Comments
 (0)