refactor: remove unnecessary conditions and test case
This commit is contained in:
parent
b7ef38b773
commit
730e39eb76
@ -6,8 +6,7 @@ import {
|
|||||||
TrackOpTypes,
|
TrackOpTypes,
|
||||||
TriggerOpTypes,
|
TriggerOpTypes,
|
||||||
DebuggerEvent,
|
DebuggerEvent,
|
||||||
markRaw,
|
markRaw
|
||||||
ref
|
|
||||||
} from '../src/index'
|
} from '../src/index'
|
||||||
import { ITERATE_KEY } from '../src/effect'
|
import { ITERATE_KEY } from '../src/effect'
|
||||||
|
|
||||||
@ -782,14 +781,4 @@ describe('reactivity/effect', () => {
|
|||||||
expect(dummy).toBe(0)
|
expect(dummy).toBe(0)
|
||||||
expect(record).toBeUndefined()
|
expect(record).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should handle self dependency mutations', () => {
|
|
||||||
const count = ref(0)
|
|
||||||
effect(() => {
|
|
||||||
count.value++
|
|
||||||
})
|
|
||||||
expect(count.value).toBe(1)
|
|
||||||
count.value = 10
|
|
||||||
expect(count.value).toBe(11)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -178,15 +178,7 @@ export function trigger(
|
|||||||
const effects = new Set<ReactiveEffect>()
|
const effects = new Set<ReactiveEffect>()
|
||||||
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
|
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
|
||||||
if (effectsToAdd) {
|
if (effectsToAdd) {
|
||||||
effectsToAdd.forEach(effect => {
|
effectsToAdd.forEach(effect => effects.add(effect))
|
||||||
if (effect !== activeEffect || !shouldTrack) {
|
|
||||||
effects.add(effect)
|
|
||||||
} else {
|
|
||||||
// the effect mutated its own dependency during its execution.
|
|
||||||
// this can be caused by operations like foo.value++
|
|
||||||
// do not trigger or we end in an infinite loop
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user