Skip to content

Commit

Permalink
fix(runtime-core): pruneCacheEntry rectify the judgment logic (fix vu…
Browse files Browse the repository at this point in the history
…ejs#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).

Author:    李想 <[email protected]>
  • Loading branch information
GRPdream committed Feb 5, 2023
1 parent 4902354 commit 58e2d71
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/runtime-core/src/components/KeepAlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
cloneVNode,
isVNode,
VNodeProps,
invokeVNodeHook
invokeVNodeHook,
isSameVNodeType
} from '../vnode'
import { warn } from '../warning'
import {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 58e2d71

Please sign in to comment.