Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/runtime-core/src/components/KeepAlive.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,7 +87,7 @@ const KeepAliveImpl: ComponentOptions ={
max: [String, Number]
},

setup(props: KeepAliveProps,{slots }: SetupContext){
setup(props: KeepAliveProps,{slots, expose }: SetupContext){
const instance = getCurrentInstance()!
// KeepAlive communicates with the instantiated renderer via the
// ctx where the renderer passes in its internals,
Expand DownExpand Up@@ -186,7 +186,7 @@ const KeepAliveImpl: ComponentOptions ={
function pruneCache(filter?: (name: string) => boolean){
cache.forEach((vnode, key) =>{
const name = getComponentName(vnode.type as ConcreteComponent)
if (name && (!filter || !filter(name))){
if (!filter || (name && !filter(name)) || !filter(key.toString())){
pruneCacheEntry(key)
}
})
Expand DownExpand Up@@ -243,6 +243,8 @@ const KeepAliveImpl: ComponentOptions ={
})
})

expose({pruneCacheEntry});

return () =>{
pendingCacheKey = null

Expand Down