File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ const genName = (name: string) => `on${name[0].toUpperCase() + name.slice(1)}`
11
11
function createLifeCycle ( lifeCyclehook : string ) {
12
12
return ( callback : Function ) => {
13
13
const vm = currentVMInFn ( genName ( lifeCyclehook ) )
14
- if ( vm ) {
15
- injectHookOption ( getVueConstructor ( ) , vm , lifeCyclehook , callback )
16
- }
14
+ return (
15
+ vm && injectHookOption ( getVueConstructor ( ) , vm , lifeCyclehook , callback )
16
+ )
17
17
}
18
18
}
19
19
@@ -25,10 +25,12 @@ function injectHookOption(
25
25
) {
26
26
const options = vm . $options as Record < string , unknown >
27
27
const mergeFn = Vue . config . optionMergeStrategies [ hook ]
28
- options [ hook ] = mergeFn ( options [ hook ] , wrapHookCall ( vm , val ) )
28
+ const wrappedHook = wrapHookCall ( vm , val )
29
+ options [ hook ] = mergeFn ( options [ hook ] , wrappedHook )
30
+ return wrappedHook
29
31
}
30
32
31
- function wrapHookCall ( vm : ComponentInstance , fn : Function ) {
33
+ function wrapHookCall ( vm : ComponentInstance , fn : Function ) : Function {
32
34
return ( ...args : any ) => {
33
35
let preVm = getCurrentInstance ( ) ?. proxy
34
36
setCurrentInstance ( vm )
You can’t perform that action at this time.
0 commit comments