Просмотр исходного кода

fix dynamic transition type for higher-order transition components (fix #4545)

Evan You 9 лет назад
Родитель
Сommit
2540c37c15
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      src/platforms/web/runtime/components/transition.js

+ 6 - 3
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 {
 export default {
   name: 'transition',
   name: 'transition',
   props: transitionProps,
   props: transitionProps,
@@ -126,11 +130,10 @@ export default {
     const oldRawChild = this._vnode
     const oldRawChild = this._vnode
     const oldChild: any = getRealChild(oldRawChild)
     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
       // replace old child transition data with fresh one
       // important for dynamic transitions!
       // important for dynamic transitions!
-      const oldData = oldChild.data.transition = extend({}, data)
-
+      const oldData = oldChild && (oldChild.data.transition = extend({}, data))
       // handle transition mode
       // handle transition mode
       if (mode === 'out-in') {
       if (mode === 'out-in') {
         // return placeholder node and queue update when leave finishes
         // return placeholder node and queue update when leave finishes