Skip to content

Commit

Permalink
refactor: remove unnecessary conditions and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 28, 2020
1 parent b7ef38b commit 730e39e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
13 changes: 1 addition & 12 deletions packages/reactivity/__tests__/effect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
TrackOpTypes,
TriggerOpTypes,
DebuggerEvent,
markRaw,
ref
markRaw
} from '../src/index'
import { ITERATE_KEY } from '../src/effect'

Expand Down Expand Up @@ -782,14 +781,4 @@ describe('reactivity/effect', () => {
expect(dummy).toBe(0)
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)
})
})
10 changes: 1 addition & 9 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,7 @@ export function trigger(
const effects = new Set<ReactiveEffect>()
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
if (effectsToAdd) {
effectsToAdd.forEach(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
}
})
effectsToAdd.forEach(effect => effects.add(effect))
}
}

Expand Down

0 comments on commit 730e39e

Please sign in to comment.