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)}`
1111function createLifeCycle ( lifeCyclehook : string ) {
1212 return ( callback : Function ) => {
1313 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+ )
1717 }
1818}
1919
@@ -25,10 +25,12 @@ function injectHookOption(
2525) {
2626 const options = vm . $options as Record < string , unknown >
2727 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
2931}
3032
31- function wrapHookCall ( vm : ComponentInstance , fn : Function ) {
33+ function wrapHookCall ( vm : ComponentInstance , fn : Function ) : Function {
3234 return ( ...args : any ) => {
3335 let preVm = getCurrentInstance ( ) ?. proxy
3436 setCurrentInstance ( vm )
You can’t perform that action at this time.
0 commit comments