fix(reactivity): effect should handle self dependency mutations

This commit is contained in:
Evan You
2020-02-18 13:22:09 -05:00
parent e1c9153b9e
commit e8e67729cb
2 changed files with 21 additions and 4 deletions

View File

@@ -210,10 +210,16 @@ function addRunners(
) {
if (effectsToAdd !== void 0) {
effectsToAdd.forEach(effect => {
if (effect.options.computed) {
computedRunners.add(effect)
if (effect !== activeEffect) {
if (effect.options.computed) {
computedRunners.add(effect)
} else {
effects.add(effect)
}
} else {
effects.add(effect)
// 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
}
})
}