@@ -86,17 +86,17 @@ export function set_active_effect(effect) {
8686/**
8787 * When sources are created within a reaction, reading and writing
8888 * them within that reaction should not cause a re-run
89- * @type {null | [active_reaction : Reaction, sources: Source[]] }
89+ * @type {null | { reaction : Reaction, sources: Source[] } }
9090 */
91- export let reaction_sources = null ;
91+ export let source_ownership = null ;
9292
9393/** @param {Value } value */
9494export function push_reaction_value ( value ) {
9595 if ( active_reaction !== null && active_reaction . f & EFFECT_IS_UPDATING ) {
96- if ( reaction_sources === null ) {
97- reaction_sources = [ active_reaction , [ value ] ] ;
96+ if ( source_ownership === null ) {
97+ source_ownership = { reaction : active_reaction , sources : [ value ] } ;
9898 } else {
99- reaction_sources [ 1 ] . push ( value ) ;
99+ source_ownership . sources . push ( value ) ;
100100 }
101101 }
102102}
@@ -235,7 +235,12 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
235235 for ( var i = 0 ; i < reactions . length ; i ++ ) {
236236 var reaction = reactions [ i ] ;
237237
238- if ( reaction_sources ?. [ 1 ] . includes ( signal ) && reaction_sources [ 0 ] === active_reaction ) continue ;
238+ if (
239+ source_ownership ?. reaction === active_reaction &&
240+ source_ownership . sources . includes ( signal )
241+ ) {
242+ continue ;
243+ }
239244
240245 if ( ( reaction . f & DERIVED ) !== 0 ) {
241246 schedule_possible_effect_self_invalidation ( /** @type {Derived } */ ( reaction ) , effect , false ) ;
@@ -257,7 +262,7 @@ export function update_reaction(reaction) {
257262 var previous_untracked_writes = untracked_writes ;
258263 var previous_reaction = active_reaction ;
259264 var previous_skip_reaction = skip_reaction ;
260- var previous_reaction_sources = reaction_sources ;
265+ var previous_reaction_sources = source_ownership ;
261266 var previous_component_context = component_context ;
262267 var previous_untracking = untracking ;
263268
@@ -270,7 +275,7 @@ export function update_reaction(reaction) {
270275 ( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
271276 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
272277
273- reaction_sources = null ;
278+ source_ownership = null ;
274279 set_component_context ( reaction . ctx ) ;
275280 untracking = false ;
276281 read_version ++ ;
@@ -358,7 +363,7 @@ export function update_reaction(reaction) {
358363 untracked_writes = previous_untracked_writes ;
359364 active_reaction = previous_reaction ;
360365 skip_reaction = previous_skip_reaction ;
361- reaction_sources = previous_reaction_sources ;
366+ source_ownership = previous_reaction_sources ;
362367 set_component_context ( previous_component_context ) ;
363368 untracking = previous_untracking ;
364369
@@ -739,7 +744,10 @@ export function get(signal) {
739744
740745 // Register the dependency on the current reaction signal.
741746 if ( active_reaction !== null && ! untracking ) {
742- if ( ! reaction_sources ?. [ 1 ] . includes ( signal ) || reaction_sources [ 0 ] !== active_reaction ) {
747+ if (
748+ source_ownership ?. reaction !== active_reaction ||
749+ ! source_ownership ?. sources . includes ( signal )
750+ ) {
743751 var deps = active_reaction . deps ;
744752 if ( signal . rv < read_version ) {
745753 signal . rv = read_version ;
0 commit comments