From: Evan You Date: Fri, 28 Jan 2022 13:02:09 +0000 (+0800) Subject: chore: simplify effectScope X-Git-Tag: v3.2.30~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81a6708739164e015affcc57bb22e820bfeee7d3;p=thirdparty%2Fvuejs%2Fcore.git chore: simplify effectScope --- diff --git a/packages/reactivity/src/effectScope.ts b/packages/reactivity/src/effectScope.ts index 7c3dbc989d..fcacab6e38 100644 --- a/packages/reactivity/src/effectScope.ts +++ b/packages/reactivity/src/effectScope.ts @@ -29,10 +29,10 @@ export class EffectScope { run(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) {