5
5
6
6
import { warn } from 'core/util/index'
7
7
import { camelize , extend } from 'shared/util'
8
- import { getRealChild , mergeVNodeHook } from 'core/vdom/helpers'
8
+ import { mergeVNodeHook , getFirstComponentChild } from 'core/vdom/helpers'
9
9
10
10
export const transitionProps = {
11
11
name : String ,
@@ -21,6 +21,17 @@ export const transitionProps = {
21
21
appearActiveClass : String
22
22
}
23
23
24
+ // in case the child is also an abstract component, e.g. <keep-alive>
25
+ // we want to recrusively retrieve the real component to be rendered
26
+ function getRealChild ( vnode : ?VNode ) : ?VNode {
27
+ const compOptions = vnode && vnode . componentOptions
28
+ if ( compOptions && compOptions . Ctor . options . abstract ) {
29
+ return getRealChild ( getFirstComponentChild ( compOptions . children ) )
30
+ } else {
31
+ return vnode
32
+ }
33
+ }
34
+
24
35
export function extractTransitionData ( comp : Component ) : Object {
25
36
const data = { }
26
37
const options = comp . $options
@@ -86,8 +97,13 @@ export default {
86
97
// use getRealChild() to ignore abstract components e.g. keep-alive
87
98
const child = getRealChild ( rawChild )
88
99
/* istanbul ignore if */
89
- if ( ! child ) return
90
- child . key = child . key || `__v${ child . tag + this . _uid } __`
100
+ if ( ! child ) {
101
+ return rawChild
102
+ }
103
+
104
+ child . key = child . key == null
105
+ ? `__v${ child . tag + this . _uid } __`
106
+ : child . key
91
107
const data = ( child . data || ( child . data = { } ) ) . transition = extractTransitionData ( this )
92
108
const oldRawChild = this . _vnode
93
109
const oldChild : any = getRealChild ( oldRawChild )
0 commit comments