@@ -61,7 +61,6 @@ export let batchDepth = 0;
6161let notifyIndex = 0 ;
6262let queuedEffectsLength = 0 ;
6363let activeSub : ReactiveNode | undefined ;
64- let activeScope : EffectScope | undefined ;
6564
6665export function getCurrentSub ( ) : ReactiveNode | undefined {
6766 return activeSub ;
@@ -73,16 +72,6 @@ export function setCurrentSub(sub: ReactiveNode | undefined) {
7372 return prevSub ;
7473}
7574
76- export function getCurrentScope ( ) : EffectScope | undefined {
77- return activeScope ;
78- }
79-
80- export function setCurrentScope ( scope : EffectScope | undefined ) {
81- const prevScope = activeScope ;
82- activeScope = scope ;
83- return prevScope ;
84- }
85-
8675export function startBatch ( ) {
8776 ++ batchDepth ;
8877}
@@ -151,8 +140,6 @@ export function effect(fn: () => void): () => void {
151140 } ;
152141 if ( activeSub !== undefined ) {
153142 link ( e , activeSub ) ;
154- } else if ( activeScope !== undefined ) {
155- link ( e , activeScope ) ;
156143 }
157144 const prev = setCurrentSub ( e ) ;
158145 try {
@@ -171,16 +158,14 @@ export function effectScope(fn: () => void): () => void {
171158 subsTail : undefined ,
172159 flags : 0 satisfies ReactiveFlags . None ,
173160 } ;
174- if ( activeScope !== undefined ) {
175- link ( e , activeScope ) ;
161+ if ( activeSub !== undefined ) {
162+ link ( e , activeSub ) ;
176163 }
177- const prevSub = setCurrentSub ( undefined ) ;
178- const prevScope = setCurrentScope ( e ) ;
164+ const prev = setCurrentSub ( e ) ;
179165 try {
180166 fn ( ) ;
181167 } finally {
182- setCurrentScope ( prevScope ) ;
183- setCurrentSub ( prevSub ) ;
168+ setCurrentSub ( prev ) ;
184169 }
185170 return effectOper . bind ( e ) ;
186171}
@@ -270,8 +255,6 @@ function computedOper<T>(this: Computed<T>): T {
270255 }
271256 if ( activeSub !== undefined ) {
272257 link ( this , activeSub ) ;
273- } else if ( activeScope !== undefined ) {
274- link ( this , activeScope ) ;
275258 }
276259 return this . value ! ;
277260}
@@ -298,8 +281,13 @@ function signalOper<T>(this: Signal<T>, ...value: [T]): T | void {
298281 }
299282 }
300283 }
301- if ( activeSub !== undefined ) {
302- link ( this , activeSub ) ;
284+ let sub = activeSub ;
285+ while ( sub !== undefined ) {
286+ if ( sub . flags & 3 as ReactiveFlags . Mutable | ReactiveFlags . Watching ) {
287+ link ( this , sub ) ;
288+ break ;
289+ }
290+ sub = sub . subs ?. sub ;
303291 }
304292 return value ;
305293 }
0 commit comments