From: 三咲智子 Kevin Deng Date: Sat, 20 Jan 2024 12:46:41 +0000 (+0800) Subject: refactor(runtime-vapor): remove ref wrapper for mounted state X-Git-Tag: v3.6.0-alpha.1~16^2~667 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a26db2adc221e0214c54eda423c488966545525;p=thirdparty%2Fvuejs%2Fcore.git refactor(runtime-vapor): remove ref wrapper for mounted state --- diff --git a/packages/runtime-vapor/src/component.ts b/packages/runtime-vapor/src/component.ts index 51be7f4ba1..267b3827dc 100644 --- a/packages/runtime-vapor/src/component.ts +++ b/packages/runtime-vapor/src/component.ts @@ -1,10 +1,4 @@ -import { - EffectScope, - type Ref, - pauseTracking, - ref, - resetTracking, -} from '@vue/reactivity' +import { EffectScope } from '@vue/reactivity' import { EMPTY_OBJ } from '@vue/shared' import type { Block } from './render' @@ -51,11 +45,9 @@ export interface ComponentInternalInstance { dirs: Map // lifecycle - get isMounted(): boolean - get isUnmounted(): boolean + isMounted: boolean + isUnmounted: boolean isUpdating: boolean - isUnmountedRef: Ref - isMountedRef: Ref // TODO: registory of provides, lifecycles, ... /** * @internal @@ -140,8 +132,6 @@ let uid = 0 export const createComponentInstance = ( component: ObjectComponent | FunctionalComponent, ): ComponentInternalInstance => { - const isMountedRef = ref(false) - const isUnmountedRef = ref(false) const instance: ComponentInternalInstance = { uid: uid++, block: null, @@ -163,21 +153,9 @@ export const createComponentInstance = ( dirs: new Map(), // lifecycle - get isMounted() { - pauseTracking() - const value = isMountedRef.value - resetTracking() - return value - }, - get isUnmounted() { - pauseTracking() - const value = isUnmountedRef.value - resetTracking() - return value - }, + isMounted: false, + isUnmounted: false, isUpdating: false, - isMountedRef, - isUnmountedRef, // TODO: registory of provides, appContext, lifecycles, ... /** * @internal diff --git a/packages/runtime-vapor/src/render.ts b/packages/runtime-vapor/src/render.ts index d335f29d30..d422db08aa 100644 --- a/packages/runtime-vapor/src/render.ts +++ b/packages/runtime-vapor/src/render.ts @@ -75,7 +75,7 @@ export function mountComponent( invokeDirectiveHook(instance, 'beforeMount') insert(block, instance.container) - instance.isMountedRef.value = true + instance.isMounted = true // hook: mounted invokeDirectiveHook(instance, 'mounted') @@ -94,8 +94,8 @@ export function unmountComponent(instance: ComponentInternalInstance) { scope.stop() block && remove(block, container) - instance.isMountedRef.value = false - instance.isUnmountedRef.value = true + instance.isMounted = false + instance.isUnmounted = true // hook: unmounted invokeDirectiveHook(instance, 'unmounted')