@@ -1,4 +1,5 @@
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
effect,
|
||||
stop,
|
||||
@@ -801,6 +802,26 @@ describe('reactivity/effect', () => {
|
||||
expect(dummy).toBe(3)
|
||||
})
|
||||
|
||||
// #5707
|
||||
// when an effect completes its run, it should clear the tracking bits of
|
||||
// its tracked deps. However, if the effect stops itself, the deps list is
|
||||
// emptied so their bits are never cleared.
|
||||
it('edge case: self-stopping effect tracking ref', () => {
|
||||
const c = ref(true)
|
||||
const runner = effect(() => {
|
||||
// reference ref
|
||||
if (!c.value) {
|
||||
// stop itself while running
|
||||
stop(runner)
|
||||
}
|
||||
})
|
||||
// trigger run
|
||||
c.value = !c.value
|
||||
// should clear bits
|
||||
expect((c as any).dep.w).toBe(0)
|
||||
expect((c as any).dep.n).toBe(0)
|
||||
})
|
||||
|
||||
it('events: onStop', () => {
|
||||
const onStop = jest.fn()
|
||||
const runner = effect(() => {}, {
|
||||
|
||||
Reference in New Issue
Block a user