]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(reactivity): effectScope.ts variable declarations optimized and remove useless...
authorHEGGRIA <34475327+HEGGRIA@users.noreply.github.com>
Wed, 28 Aug 2024 10:16:59 +0000 (18:16 +0800)
committerGitHub <noreply@github.com>
Wed, 28 Aug 2024 10:16:59 +0000 (18:16 +0800)
* chore(reactivity): effectScope.ts variable declarations optimized and remove useless code in effect.ts

* fix(reactivity): batchDepth count error fixed

* fix(reactivity): batchDepth count error fixed

* chore(reactivity): modify the batchDepth increase type

packages/reactivity/src/effect.ts
packages/reactivity/src/effectScope.ts

index c769ba57d8c4dc979c8d24dddd05ba4317824d72..11d832442891b76d610d6d6bfb53a2dbe9bc3ddb 100644 (file)
@@ -258,12 +258,10 @@ export function startBatch(): void {
  * @internal
  */
 export function endBatch(): void {
-  if (batchDepth > 1) {
-    batchDepth--
+  if (--batchDepth > 0) {
     return
   }
 
-  batchDepth--
   let error: unknown
   while (batchedEffect) {
     let e: ReactiveEffect | undefined = batchedEffect
index 898a7cb027229c7d94e4e2dba916f7472b9eef6b..4fa9686083c772b9e5c6ae8626201c7fc37eee94 100644 (file)
@@ -53,12 +53,13 @@ export class EffectScope {
   pause(): void {
     if (this._active) {
       this._isPaused = true
+      let i, l
       if (this.scopes) {
-        for (let i = 0, l = this.scopes.length; i < l; i++) {
+        for (i = 0, l = this.scopes.length; i < l; i++) {
           this.scopes[i].pause()
         }
       }
-      for (let i = 0, l = this.effects.length; i < l; i++) {
+      for (i = 0, l = this.effects.length; i < l; i++) {
         this.effects[i].pause()
       }
     }
@@ -71,12 +72,13 @@ export class EffectScope {
     if (this._active) {
       if (this._isPaused) {
         this._isPaused = false
+        let i, l
         if (this.scopes) {
-          for (let i = 0, l = this.scopes.length; i < l; i++) {
+          for (i = 0, l = this.scopes.length; i < l; i++) {
             this.scopes[i].resume()
           }
         }
-        for (let i = 0, l = this.effects.length; i < l; i++) {
+        for (i = 0, l = this.effects.length; i < l; i++) {
           this.effects[i].resume()
         }
       }