From fa40d1ef3a18f5402c4374c24c1de632a4745e56 Mon Sep 17 00:00:00 2001 From: limichange Date: Tue, 21 Apr 2020 01:39:35 +0800 Subject: [PATCH] refactor(reactivity): simplify if condition (#1002) --- packages/reactivity/src/effect.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index aab4ae6d..4bb97733 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -141,11 +141,11 @@ export function track(target: object, type: TrackOpTypes, key: unknown) { return } let depsMap = targetMap.get(target) - if (depsMap === void 0) { + if (!depsMap) { targetMap.set(target, (depsMap = new Map())) } let dep = depsMap.get(key) - if (dep === void 0) { + if (!dep) { depsMap.set(key, (dep = new Set())) } if (!dep.has(activeEffect)) { @@ -171,7 +171,7 @@ export function trigger( oldTarget?: Map | Set ) { const depsMap = targetMap.get(target) - if (depsMap === void 0) { + if (!depsMap) { // never been tracked return } @@ -179,7 +179,7 @@ export function trigger( const effects = new Set() const computedRunners = new Set() const add = (effectsToAdd: Set | undefined) => { - if (effectsToAdd !== void 0) { + if (effectsToAdd) { effectsToAdd.forEach(effect => { if (effect !== activeEffect || !shouldTrack) { if (effect.options.computed) { @@ -238,7 +238,7 @@ export function trigger( oldTarget }) } - if (effect.options.scheduler !== void 0) { + if (effect.options.scheduler) { effect.options.scheduler(effect) } else { effect()