From c65d6def843d496622b08230a59da378a1eb0007 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 15 Sep 2020 09:47:58 +0800 Subject: [PATCH] polish: warn deprecated beforeDestroy/destroyed lifecycle hooks (#1999) --- packages/runtime-core/src/componentOptions.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 672cb8af9..dec584ae8 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -316,7 +316,11 @@ interface LegacyOptions< updated?(): void activated?(): void deactivated?(): void + /** @deprecated use `beforeUnmount` instead */ + beforeDestroy?(): void beforeUnmount?(): void + /** @deprecated use `unmounted` instead */ + destroyed?(): void unmounted?(): void renderTracked?: DebuggerHook renderTriggered?: DebuggerHook @@ -393,7 +397,9 @@ export function applyOptions( updated, activated, deactivated, + beforeDestroy, beforeUnmount, + destroyed, unmounted, render, renderTracked, @@ -631,9 +637,19 @@ export function applyOptions( if (renderTriggered) { onRenderTriggered(renderTriggered.bind(publicThis)) } + if (__DEV__ && beforeDestroy) { + warn( + `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.` + ) + } if (beforeUnmount) { onBeforeUnmount(beforeUnmount.bind(publicThis)) } + if (__DEV__ && destroyed) { + warn( + `\`destroyed\` has been renamed to \`unmounted\`.` + ) + } if (unmounted) { onUnmounted(unmounted.bind(publicThis)) }