1
1
import { DEV } from 'esm-env' ;
2
- import { get , batch_inspect , current_component_context , untrack } from './runtime.js' ;
3
- import { effect_active } from './reactivity/effects.js' ;
2
+ import {
3
+ get ,
4
+ batch_inspect ,
5
+ current_component_context ,
6
+ untrack ,
7
+ current_effect
8
+ } from './runtime.js' ;
4
9
import {
5
10
array_prototype ,
6
11
define_property ,
@@ -206,7 +211,7 @@ const state_proxy_handler = {
206
211
// but only if it's an own property and not a prototype property
207
212
if (
208
213
s === undefined &&
209
- ( effect_active ( ) || updating_derived ) &&
214
+ ( current_effect !== null || updating_derived ) &&
210
215
( ! ( prop in target ) || get_descriptor ( target , prop ) ?. writable )
211
216
) {
212
217
s = ( metadata . i ? source : mutable_source ) ( proxy ( target [ prop ] , metadata . i , metadata . o ) ) ;
@@ -250,7 +255,10 @@ const state_proxy_handler = {
250
255
const has = Reflect . has ( target , prop ) ;
251
256
252
257
let s = metadata . s . get ( prop ) ;
253
- if ( s !== undefined || ( effect_active ( ) && ( ! has || get_descriptor ( target , prop ) ?. writable ) ) ) {
258
+ if (
259
+ s !== undefined ||
260
+ ( current_effect !== null && ( ! has || get_descriptor ( target , prop ) ?. writable ) )
261
+ ) {
254
262
if ( s === undefined ) {
255
263
s = ( metadata . i ? source : mutable_source ) (
256
264
has ? proxy ( target [ prop ] , metadata . i , metadata . o ) : UNINITIALIZED
@@ -273,7 +281,7 @@ const state_proxy_handler = {
273
281
// we do so otherwise if we read it later, then the write won't be tracked and
274
282
// the heuristics of effects will be different vs if we had read the proxied
275
283
// object property before writing to that property.
276
- if ( s === undefined && effect_active ( ) ) {
284
+ if ( s === undefined && current_effect !== null ) {
277
285
// the read creates a signal
278
286
untrack ( ( ) => receiver [ prop ] ) ;
279
287
s = metadata . s . get ( prop ) ;
0 commit comments