From: Haoqun Jiang Date: Tue, 15 Sep 2020 01:47:58 +0000 (+0800) Subject: polish: warn deprecated beforeDestroy/destroyed lifecycle hooks (#1999) X-Git-Tag: v3.0.0-rc.11~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c65d6def843d496622b08230a59da378a1eb0007;p=thirdparty%2Fvuejs%2Fcore.git polish: warn deprecated beforeDestroy/destroyed lifecycle hooks (#1999) --- diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index 672cb8af92..dec584ae8b 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)) }