diff --git a/src/platforms/web/runtime/components/transition.js b/src/platforms/web/runtime/components/transition.js index b94a16c97..fb05b692e 100644 --- a/src/platforms/web/runtime/components/transition.js +++ b/src/platforms/web/runtime/components/transition.js @@ -2,7 +2,7 @@ // supports transition mode (out-in / in-out) import { warn } from 'core/util/index' -import { noop, camelize } from 'shared/util' +import { camelize } from 'shared/util' import { getRealChild, mergeVNodeHook } from 'core/vdom/helpers' export const transitionProps = { @@ -110,16 +110,11 @@ export default { } else if (mode === 'in-out') { let delayedLeave const performLeave = () => { delayedLeave() } - mergeVNodeHook(data, 'afterEnter', performLeave) mergeVNodeHook(data, 'enterCancelled', performLeave) - mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave }) - mergeVNodeHook(oldData, 'leaveCancelled', () => { - delayedLeave = noop - }) } } diff --git a/src/platforms/web/runtime/modules/transition.js b/src/platforms/web/runtime/modules/transition.js index 1d846097f..566f22010 100644 --- a/src/platforms/web/runtime/modules/transition.js +++ b/src/platforms/web/runtime/modules/transition.js @@ -160,6 +160,10 @@ export function leave (vnode: VNodeWithData, rm: Function) { } function performLeave () { + // the delayed leave may have already been cancelled + if (cb.cancelled) { + return + } // record leaving element if (!vnode.data.show) { (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode diff --git a/test/unit/features/component/component-keep-alive.spec.js b/test/unit/features/component/component-keep-alive.spec.js index ec0d87745..7b5a176d0 100644 --- a/test/unit/features/component/component-keep-alive.spec.js +++ b/test/unit/features/component/component-keep-alive.spec.js @@ -260,5 +260,71 @@ describe('Component keep-alive', () => { assertHookCalls(two, [1, 1, 1, 1, 0]) }).then(done) }) + + it('dynamic components, in-out with early cancel', done => { + let next + const vm = new Vue({ + template: `