fix(reactivity): add back STOP flag (#13605)
ci / test (push) Has been cancelled Details
ci / continuous-release (push) Has been cancelled Details
size data / upload (push) Has been cancelled Details

This commit is contained in:
Johnson Chu 2025-07-10 17:14:59 +08:00 committed by GitHub
parent c14171e6e5
commit b4d8e7184c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -52,6 +52,7 @@ export enum EffectFlags {
*/
ALLOW_RECURSE = 1 << 7,
PAUSED = 1 << 8,
STOP = 1 << 10,
}
export class ReactiveEffect<T = any>
@ -90,7 +91,7 @@ export class ReactiveEffect<T = any>
}
get active(): boolean {
return !!this.flags || this.deps !== undefined
return !(this.flags & EffectFlags.STOP)
}
pause(): void {
@ -132,6 +133,10 @@ export class ReactiveEffect<T = any>
}
stop(): void {
if (!this.active) {
return
}
this.flags = EffectFlags.STOP
let dep = this.deps
while (dep !== undefined) {
dep = unlink(dep, this)
@ -140,7 +145,6 @@ export class ReactiveEffect<T = any>
if (sub !== undefined) {
unlink(sub)
}
this.flags = 0
cleanup(this)
}

View File

@ -33,7 +33,7 @@ export class EffectScope implements ReactiveNode {
}
get active(): boolean {
return !!this.flags || this.deps !== undefined
return !(this.flags & EffectFlags.STOP)
}
pause(): void {
@ -77,6 +77,10 @@ export class EffectScope implements ReactiveNode {
}
stop(): void {
if (!this.active) {
return
}
this.flags = EffectFlags.STOP
let dep = this.deps
while (dep !== undefined) {
const node = dep.dep
@ -91,7 +95,6 @@ export class EffectScope implements ReactiveNode {
if (sub !== undefined) {
unlink(sub)
}
this.flags = 0
cleanup(this)
}
}