33import { isIE9 } from 'web/util/index'
44import { enter , leave } from '../modules/transition'
55
6- // The v-show directive may appear on a component's parent vnode or its
7- // inner vnode, and the transition wrapper may be defined outside or inside
8- // the component. To cater for all possible cases, recursively search for
9- // possible transition defined on component parent placeholder or inside
10- // child component.
11- function detectTransitionNode ( vnode : VNode ) : VNodeWithData {
12- let parent = vnode
13- while ( ( parent = parent . parent ) ) {
14- if ( hasTransition ( parent ) ) {
15- return parent
16- }
17- }
18- if ( hasTransition ( vnode ) ) {
19- return vnode
20- }
21- while ( vnode . child && ( vnode = vnode . child . _vnode ) ) {
22- if ( hasTransition ( vnode ) ) {
23- return vnode
24- }
25- }
26- return vnode
27- }
28-
29- function hasTransition ( vnode ) {
30- return vnode . data && vnode . data . transition
6+ // recursively search for possible transition defined inside the component root
7+ function locateNode ( vnode : VNode ) : VNodeWithData {
8+ return vnode . child && ( ! vnode . data || ! vnode . data . transition )
9+ ? locateNode ( vnode . child . _vnode )
10+ : vnode
3111}
3212
3313export default {
3414 bind ( el : any , { value } : VNodeDirective, vnode : VNodeWithData ) {
35- vnode = detectTransitionNode ( vnode )
15+ vnode = locateNode ( vnode )
3616 const transition = vnode . data && vnode . data . transition
3717 if ( value && transition && transition . appear && ! isIE9 ) {
3818 enter ( vnode )
@@ -44,7 +24,7 @@ export default {
4424 update ( el : any , { value, oldValue } : VNodeDirective , vnode : VNodeWithData ) {
4525 /* istanbul ignore if */
4626 if ( value === oldValue ) return
47- vnode = detectTransitionNode ( vnode )
27+ vnode = locateNode ( vnode )
4828 const transition = vnode . data && vnode . data . transition
4929 if ( transition && ! isIE9 ) {
5030 if ( value ) {
0 commit comments