diff --git a/src/core/vdom/patch.js b/src/core/vdom/patch.js index f655a7b4..6d6444b3 100644 --- a/src/core/vdom/patch.js +++ b/src/core/vdom/patch.js @@ -202,7 +202,10 @@ export function createPatchFunction (backend) { if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode) for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode) } - if (isDef(i = vnode.child) && !data.keepAlive) { + if (isDef(i = vnode.child) && ( + !data.keepAlive || + vnode.context._isBeingDestroyed + )) { invokeDestroyHook(i._vnode) } if (isDef(i = vnode.children)) { diff --git a/test/unit/features/component/component-keep-alive.spec.js b/test/unit/features/component/component-keep-alive.spec.js index d140ecf4..ca830522 100644 --- a/test/unit/features/component/component-keep-alive.spec.js +++ b/test/unit/features/component/component-keep-alive.spec.js @@ -82,6 +82,31 @@ describe('Component keep-alive', () => { }).then(done) }) + // #3882 + it('deeply nested keep-alive should be destroyed properly', done => { + one.template = `