@@ -11,6 +11,10 @@ function getRealChild (vnode: ?VNode): ?VNode {
11
11
}
12
12
}
13
13
14
+ function isSameChild ( child : VNode , oldChild : VNode ) : boolean {
15
+ return oldChild . key === child . key && oldChild . tag === child . tag
16
+ }
17
+
14
18
function getFirstComponentChild ( children : ?Array < VNode > ) : ?VNode {
15
19
if ( Array . isArray ( children ) ) {
16
20
for ( let i = 0 ; i < children . length ; i ++ ) {
@@ -22,6 +26,16 @@ function getFirstComponentChild (children: ?Array<VNode>): ?VNode {
22
26
}
23
27
}
24
28
29
+ function isPrimitive ( value : any ) : boolean % checks {
30
+ return (
31
+ typeof value === 'string' ||
32
+ typeof value === 'number' ||
33
+ // $flow-disable-line
34
+ typeof value === 'symbol' ||
35
+ typeof value === 'boolean'
36
+ )
37
+ }
38
+
25
39
function isAsyncPlaceholder ( node : VNode ) : boolean {
26
40
return node . isComment && node . asyncFactory
27
41
}
@@ -102,14 +116,37 @@ export default {
102
116
return rawChild
103
117
}
104
118
105
- ( child . data || ( child . data = { } ) ) . transition = extractTransitionData ( this )
119
+ const id : string = `__transition - $ { this . _uid } - `
120
+ child . key = child . key == null
121
+ ? child . isComment
122
+ ? id + 'comment'
123
+ : id + child . tag
124
+ : isPrimitive ( child . key )
125
+ ? ( String ( child . key ) . indexOf ( id ) === 0 ? child . key : id + child . key )
126
+ : child . key
127
+
128
+ const data : Object = ( child . data || ( child . data = { } ) ) . transition = extractTransitionData ( this )
129
+ const oldRawChild : VNode = this . _vnode
130
+ const oldChild : VNode = getRealChild ( oldRawChild )
131
+ if ( child . data . directives && child . data . directives . some ( d => d . name === 'show' ) ) {
132
+ child . data . show = true
133
+ }
106
134
107
135
// mark v-show
108
136
// so that the transition module can hand over the control to the directive
109
137
if ( child . data . directives && child . data . directives . some ( d => d . name === 'show' ) ) {
110
138
child . data . show = true
111
139
}
112
-
140
+ if (
141
+ oldChild &&
142
+ oldChild . data &&
143
+ ! isSameChild ( child , oldChild ) &&
144
+ ! isAsyncPlaceholder ( oldChild ) &&
145
+ // #6687 component root is a comment node
146
+ ! ( oldChild . componentInstance && oldChild . componentInstance . _vnode . isComment )
147
+ ) {
148
+ oldChild . data = { ...data }
149
+ }
113
150
return rawChild
114
151
}
115
152
}
0 commit comments