]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: simplify effectScope
authorEvan You <yyx990803@gmail.com>
Fri, 28 Jan 2022 13:02:09 +0000 (21:02 +0800)
committerEvan You <yyx990803@gmail.com>
Fri, 28 Jan 2022 13:02:09 +0000 (21:02 +0800)
packages/reactivity/src/effectScope.ts

index 7c3dbc989d17ede4deac135072768103696b6db3..fcacab6e381dd3e34dd328116932b1115ad9142e 100644 (file)
@@ -29,10 +29,10 @@ export class EffectScope {
   run<T>(fn: () => T): T | undefined {
     if (this.active) {
       try {
-        this.on()
+        activeEffectScope = this
         return fn()
       } finally {
-        this.off()
+        activeEffectScope = this.parent
       }
     } else if (__DEV__) {
       warn(`cannot run an inactive effect scope.`)
@@ -40,15 +40,11 @@ export class EffectScope {
   }
 
   on() {
-    if (this.active) {
-      activeEffectScope = this
-    }
+    activeEffectScope = this
   }
 
   off() {
-    if (this.active) {
-      activeEffectScope = this.parent
-    }
+    activeEffectScope = this.parent
   }
 
   stop(fromParent?: boolean) {