|
|
@@ -767,55 +767,44 @@ export function applyOptions(
|
|
|
globalMixins
|
|
|
)
|
|
|
}
|
|
|
- if (beforeMount) {
|
|
|
- onBeforeMount(beforeMount.bind(publicThis))
|
|
|
- }
|
|
|
- if (mounted) {
|
|
|
- onMounted(mounted.bind(publicThis))
|
|
|
- }
|
|
|
- if (beforeUpdate) {
|
|
|
- onBeforeUpdate(beforeUpdate.bind(publicThis))
|
|
|
- }
|
|
|
- if (updated) {
|
|
|
- onUpdated(updated.bind(publicThis))
|
|
|
- }
|
|
|
- if (activated) {
|
|
|
- onActivated(activated.bind(publicThis))
|
|
|
- }
|
|
|
- if (deactivated) {
|
|
|
- onDeactivated(deactivated.bind(publicThis))
|
|
|
- }
|
|
|
- if (errorCaptured) {
|
|
|
- onErrorCaptured(errorCaptured.bind(publicThis))
|
|
|
- }
|
|
|
- if (renderTracked) {
|
|
|
- onRenderTracked(renderTracked.bind(publicThis))
|
|
|
- }
|
|
|
- if (renderTriggered) {
|
|
|
- onRenderTriggered(renderTriggered.bind(publicThis))
|
|
|
- }
|
|
|
- if (beforeUnmount) {
|
|
|
- onBeforeUnmount(beforeUnmount.bind(publicThis))
|
|
|
- }
|
|
|
- if (unmounted) {
|
|
|
- onUnmounted(unmounted.bind(publicThis))
|
|
|
- }
|
|
|
- if (serverPrefetch) {
|
|
|
- onServerPrefetch(serverPrefetch.bind(publicThis))
|
|
|
+
|
|
|
+ function registerLifecycleHook(
|
|
|
+ register: Function,
|
|
|
+ hook?: Function | Function[]
|
|
|
+ ) {
|
|
|
+ // Array lifecycle hooks are only present in the compat build
|
|
|
+ if (__COMPAT__ && isArray(hook)) {
|
|
|
+ hook.forEach(_hook => register(_hook.bind(publicThis)))
|
|
|
+ } else if (hook) {
|
|
|
+ register((hook as Function).bind(publicThis))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ registerLifecycleHook(onBeforeMount, beforeMount)
|
|
|
+ registerLifecycleHook(onMounted, mounted)
|
|
|
+ registerLifecycleHook(onBeforeUpdate, beforeUpdate)
|
|
|
+ registerLifecycleHook(onUpdated, updated)
|
|
|
+ registerLifecycleHook(onActivated, activated)
|
|
|
+ registerLifecycleHook(onDeactivated, deactivated)
|
|
|
+ registerLifecycleHook(onErrorCaptured, errorCaptured)
|
|
|
+ registerLifecycleHook(onRenderTracked, renderTracked)
|
|
|
+ registerLifecycleHook(onRenderTriggered, renderTriggered)
|
|
|
+ registerLifecycleHook(onBeforeUnmount, beforeUnmount)
|
|
|
+ registerLifecycleHook(onUnmounted, unmounted)
|
|
|
+ registerLifecycleHook(onServerPrefetch, serverPrefetch)
|
|
|
+
|
|
|
if (__COMPAT__) {
|
|
|
if (
|
|
|
beforeDestroy &&
|
|
|
softAssertCompatEnabled(DeprecationTypes.OPTIONS_BEFORE_DESTROY, instance)
|
|
|
) {
|
|
|
- onBeforeUnmount(beforeDestroy.bind(publicThis))
|
|
|
+ registerLifecycleHook(onBeforeUnmount, beforeDestroy)
|
|
|
}
|
|
|
if (
|
|
|
destroyed &&
|
|
|
softAssertCompatEnabled(DeprecationTypes.OPTIONS_DESTROYED, instance)
|
|
|
) {
|
|
|
- onUnmounted(destroyed.bind(publicThis))
|
|
|
+ registerLifecycleHook(onUnmounted, destroyed)
|
|
|
}
|
|
|
}
|
|
|
|