]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(reactivity): simplify if condition (#1002)
authorlimichange <limichange@hotmail.com>
Mon, 20 Apr 2020 17:39:35 +0000 (01:39 +0800)
committerGitHub <noreply@github.com>
Mon, 20 Apr 2020 17:39:35 +0000 (13:39 -0400)
packages/reactivity/src/effect.ts

index aab4ae6db6ab7f0790674520b32aea6d4110ca9e..4bb977337be9266d97015e61926f1948ba8b32d9 100644 (file)
@@ -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<unknown, unknown> | Set<unknown>
 ) {
   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<ReactiveEffect>()
   const computedRunners = new Set<ReactiveEffect>()
   const add = (effectsToAdd: Set<ReactiveEffect> | 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()