diff --git a/packages/reactivity/__tests__/computed.spec.ts b/packages/reactivity/__tests__/computed.spec.ts index 20faa18a323..97e176979fd 100644 --- a/packages/reactivity/__tests__/computed.spec.ts +++ b/packages/reactivity/__tests__/computed.spec.ts @@ -123,21 +123,6 @@ describe('reactivity/computed', () => { expect(getter2).toHaveBeenCalledTimes(2) }) - it('should no longer update when stopped', () => { - const value = reactive<{ foo?: number }>({}) - const cValue = computed(() => value.foo) - let dummy - effect(() => { - dummy = cValue.value - }) - expect(dummy).toBe(undefined) - value.foo = 1 - expect(dummy).toBe(1) - cValue.effect.stop() - value.foo = 2 - expect(dummy).toBe(1) - }) - it('should support setter', () => { const n = ref(1) const plusOne = computed({ diff --git a/packages/reactivity/__tests__/deferredComputed.spec.ts b/packages/reactivity/__tests__/deferredComputed.spec.ts index 8e78ba959c3..3df8859a7fc 100644 --- a/packages/reactivity/__tests__/deferredComputed.spec.ts +++ b/packages/reactivity/__tests__/deferredComputed.spec.ts @@ -136,20 +136,4 @@ describe('deferred computed', () => { c2.value expect(effectSpy).toHaveBeenCalledTimes(2) }) - - test('should not compute if deactivated before scheduler is called', () => { - const c1Spy = vi.fn() - const src = ref(0) - const c1 = computed(() => { - c1Spy() - return src.value % 2 - }) - effect(() => c1.value) - expect(c1Spy).toHaveBeenCalledTimes(1) - - c1.effect.stop() - // trigger - src.value++ - expect(c1Spy).toHaveBeenCalledTimes(1) - }) }) diff --git a/packages/reactivity/__tests__/effectScope.spec.ts b/packages/reactivity/__tests__/effectScope.spec.ts index e0aa06f3dbf..f7fc7ed3aba 100644 --- a/packages/reactivity/__tests__/effectScope.spec.ts +++ b/packages/reactivity/__tests__/effectScope.spec.ts @@ -268,8 +268,7 @@ describe('reactivity/effect/scope', () => { r.value++ c!.value await nextTick() - // should not trigger anymore - expect(computedSpy).toHaveBeenCalledTimes(2) + expect(computedSpy).toHaveBeenCalledTimes(3) expect(watchSpy).toHaveBeenCalledTimes(1) expect(watchEffectSpy).toHaveBeenCalledTimes(2) }) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index 1528f4b1d89..3228a7eb3f9 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -125,7 +125,7 @@ export class ReactiveEffect { } stop() { - if (this.active) { + if (this.active && !this.computed) { preCleanupEffect(this) postCleanupEffect(this) this.onStop && this.onStop() diff --git a/packages/runtime-core/__tests__/apiSetupHelpers.spec.ts b/packages/runtime-core/__tests__/apiSetupHelpers.spec.ts index 04e9c1c86db..dd6eef5a3f8 100644 --- a/packages/runtime-core/__tests__/apiSetupHelpers.spec.ts +++ b/packages/runtime-core/__tests__/apiSetupHelpers.spec.ts @@ -1,9 +1,7 @@ import { type ComponentInternalInstance, - type ComputedRef, type SetupContext, Suspense, - computed, createApp, defineComponent, getCurrentInstance, @@ -419,38 +417,5 @@ describe('SFC