8000 fix(lifecycle): deactivated should not run on unmounted lifecycle (#217) · aztalbot/vue-function-api@42c582a · GitHub
[go: up one dir, main page]

Skip to content

Commit 42c582a

Browse files
authored
fix(lifecycle): deactivated should not run on unmounted lifecycle (vuejs#217)
close vuejs#178
1 parent 3463fbc commit 42c582a

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/apis/lifecycle.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ function createLifeCycle(lifeCyclehook: string) {
1111
};
1212
}
1313

14-
function createLifeCycles(lifeCyclehooks: string[], name: string) {
15-
return (callback: Function) => {
16-
const currentVue = getCurrentVue();
17-
const vm = ensureCurrentVMInFn(name);
18-
lifeCyclehooks.forEach(lifeCyclehook =>
19-
injectHookOption(currentVue, vm, lifeCyclehook, callback)
20-
);
21-
};
22-
}
23-
2414
function injectHookOption(Vue: VueConstructor, vm: ComponentInstance, hook: string, val: Function) {
2515
const options = vm.$options as any;
2616
const mergeFn = Vue.config.optionMergeStrategies[hook];
@@ -33,8 +23,7 @@ export const onMounted = createLifeCycle('mounted');
3323
export const onBeforeUpdate = createLifeCycle('beforeUpdate');
3424
export const onUpdated = createLifeCycle('updated');
3525
export const onBeforeUnmount = createLifeCycle('beforeDestroy');
36-
// only one event will be fired between destroyed and deactivated when an unmount occurs
37-
export const onUnmounted = createLifeCycles(['destroyed', 'deactivated'], genName('unmounted'));
26+
export const onUnmounted = createLifeCycle('destroyed');
3827
export const onErrorCaptured = createLifeCycle('errorCaptured');
3928
export const onActivated = createLifeCycle('activated');
4029
export const onDeactivated = createLifeCycle('deactivated');

0 commit comments

Comments
 (0)
0