Explorar o código

chore: simplify effectScope

Evan You %!s(int64=4) %!d(string=hai) anos
pai
achega
81a6708739
Modificáronse 1 ficheiros con 4 adicións e 8 borrados
  1. 4 8
      packages/reactivity/src/effectScope.ts

+ 4 - 8
packages/reactivity/src/effectScope.ts

@@ -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) {