@@ -83,11 +83,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
83
83
}
84
84
85
85
const expectsCSS = css !== false && ! isIE9
86
- const userWantsControl =
87
- enterHook &&
88
- // enterHook may be a bound method which exposes
89
- // the length of original fn as _length
90
- ( enterHook . _length || enterHook . length ) > 1
86
+ const userWantsControl = getHookAgumentsLength ( enterHook )
91
87
92
88
const cb = el . _enterCb = once ( ( ) => {
93
89
if ( expectsCSS ) {
@@ -116,7 +112,7 @@ export function enter (vnode: VNodeWithData, toggleDisplay: ?() => void) {
116
112
pendingNode . elm . _leaveCb ( )
117
113
}
118
114
enterHook && enterHook ( el , cb )
119
- } , 'transition-insert' )
115
+ } )
120
116
}
121
117
122
118
// start enter transition
@@ -181,11 +177,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
181
177
} = data
182
178
183
179
const expectsCSS = css !== false && ! isIE9
184
- const userWantsControl =
185
- leave &&
186
- // leave hook may be a bound method which exposes
187
- // the length of original fn as _length
188
- ( leave . _length || leave . length ) > 1
180
+ const userWantsControl = getHookAgumentsLength ( leave )
189
181
190
182
const explicitLeaveDuration = isObject ( duration ) ? duration . leave : duration
191
183
if ( process . env . NODE_ENV !== 'production' && explicitLeaveDuration != null ) {
@@ -271,6 +263,27 @@ function isValidDuration (val) {
271
263
return typeof val === 'number' && ! isNaN ( val )
272
264
}
273
265
266
+ /**
267
+ * Normalize a transition hook's argument length. The hook may be:
268
+ * - a merged hook (invoker) with the original in .fns
269
+ * - a wrapped component method (check ._length)
270
+ * - a plain function (.length)
271
+ */
272
+ function getHookAgumentsLength ( fn : Function ) : boolean {
273
+ if ( ! fn ) return false
274
+ const invokerFns = fn . fns
275
+ if ( invokerFns ) {
276
+ // invoker
277
+ return getHookAgumentsLength (
278
+ Array . isArray ( invokerFns )
279
+ ? invokerFns [ 0 ]
280
+ : invokerFns
281
+ )
282
+ } else {
283
+ return ( fn . _length || fn . length ) > 1
284
+ }
285
+ }
286
+
274
287
function _enter ( _ : any , vnode : VNodeWithData ) {
275
288
if ( ! vnode . data . show ) {
276
289
enter ( vnode )
0 commit comments