diff --git a/src/core/components/keep-alive.ts b/src/core/components/keep-alive.ts index 2bb2206be37..b82152987e5 100644 --- a/src/core/components/keep-alive.ts +++ b/src/core/components/keep-alive.ts @@ -33,10 +33,15 @@ function matches( } function pruneCache( - keepAliveInstance: { cache: CacheEntryMap; keys: string[]; _vnode: VNode }, + keepAliveInstance: { + cache: CacheEntryMap + keys: string[] + _vnode: VNode + $vnode: VNode + }, filter: Function ) { - const { cache, keys, _vnode } = keepAliveInstance + const { cache, keys, _vnode, $vnode } = keepAliveInstance for (const key in cache) { const entry = cache[key] if (entry) { @@ -46,6 +51,7 @@ function pruneCache( } } } + $vnode.componentOptions!.children = undefined } function pruneCacheEntry( diff --git a/src/core/vdom/create-component.ts b/src/core/vdom/create-component.ts index d3a42eebccb..9e48c575230 100644 --- a/src/core/vdom/create-component.ts +++ b/src/core/vdom/create-component.ts @@ -62,8 +62,6 @@ const componentVNodeHooks = { vnode, // new parent vnode options.children // new children ) - // #12187 unset children reference after use to avoid memory leak - options.children = undefined }, insert(vnode: MountedComponentVNode) {