From 2540c37c15eed42cbbcf576545406097ec46a6e3 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 27 Dec 2016 12:10:13 -0500 Subject: [PATCH] fix dynamic transition type for higher-order transition components (fix #4545) --- src/platforms/web/runtime/components/transition.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/platforms/web/runtime/components/transition.js b/src/platforms/web/runtime/components/transition.js index 3c1b87ac0c1..8922a7661ac 100644 --- a/src/platforms/web/runtime/components/transition.js +++ b/src/platforms/web/runtime/components/transition.js @@ -62,6 +62,10 @@ function hasParentTransition (vnode) { } } +function isSameChild (child, oldChild) { + return oldChild.key === child.key && oldChild.tag === child.tag +} + export default { name: 'transition', props: transitionProps, @@ -126,11 +130,10 @@ export default { const oldRawChild = this._vnode const oldChild: any = getRealChild(oldRawChild) - if (oldChild && oldChild.data && oldChild.key !== key) { + if (oldChild && oldChild.data && !isSameChild(child, oldChild)) { // replace old child transition data with fresh one // important for dynamic transitions! - const oldData = oldChild.data.transition = extend({}, data) - + const oldData = oldChild && (oldChild.data.transition = extend({}, data)) // handle transition mode if (mode === 'out-in') { // return placeholder node and queue update when leave finishes