@@ -88,17 +88,24 @@ export function set_active_effect(effect) {
8888/**
8989 * When sources are created within a reaction, reading and writing
9090 * them within that reaction should not cause a re-run
91- * @type {null | { reaction: Reaction, sources: Source[] } }
91+ * @type {null | Source[] }
9292 */
93- export let source_ownership = null ;
93+ export let current_sources = null ;
94+
95+ /**
96+ * @param {null | Source[] } value
97+ */
98+ export function set_current_sources ( value ) {
99+ current_sources = value ;
100+ }
94101
95102/** @param {Value } value */
96103export function push_reaction_value ( value ) {
97104 if ( active_reaction !== null && active_reaction . f & EFFECT_IS_UPDATING ) {
98- if ( source_ownership === null ) {
99- source_ownership = { reaction : active_reaction , sources : [ value ] } ;
105+ if ( current_sources === null ) {
106+ current_sources = [ value ] ;
100107 } else {
101- source_ownership . sources . push ( value ) ;
108+ current_sources . push ( value ) ;
102109 }
103110 }
104111}
@@ -236,7 +243,7 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
236243 var reactions = signal . reactions ;
237244 if ( reactions === null ) return ;
238245
239- if ( source_ownership ?. reaction === active_reaction && source_ownership . sources . includes ( signal ) ) {
246+ if ( current_sources ? .includes ( signal ) ) {
240247 return ;
241248 }
242249
@@ -263,7 +270,7 @@ export function update_reaction(reaction) {
263270 var previous_untracked_writes = untracked_writes ;
264271 var previous_reaction = active_reaction ;
265272 var previous_skip_reaction = skip_reaction ;
266- var previous_reaction_sources = source_ownership ;
273+ var previous_sources = current_sources ;
267274 var previous_component_context = component_context ;
268275 var previous_untracking = untracking ;
269276 var previous_update_version = update_version ;
@@ -277,7 +284,7 @@ export function update_reaction(reaction) {
277284 ( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
278285 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
279286
280- source_ownership = null ;
287+ current_sources = null ;
281288 set_component_context ( reaction . ctx ) ;
282289 untracking = false ;
283290 update_version = ++ read_version ;
@@ -365,7 +372,7 @@ export function update_reaction(reaction) {
365372 untracked_writes = previous_untracked_writes ;
366373 active_reaction = previous_reaction ;
367374 skip_reaction = previous_skip_reaction ;
368- source_ownership = previous_reaction_sources ;
375+ current_sources = previous_sources ;
369376 set_component_context ( previous_component_context ) ;
370377 untracking = previous_untracking ;
371378 update_version = previous_update_version ;
@@ -759,10 +766,7 @@ export function get(signal) {
759766
760767 // Register the dependency on the current reaction signal.
761768 if ( active_reaction !== null && ! untracking ) {
762- if (
763- source_ownership ?. reaction !== active_reaction ||
764- ! source_ownership ?. sources . includes ( signal )
765- ) {
769+ if ( ! current_sources ?. includes ( signal ) ) {
766770 var deps = active_reaction . deps ;
767771 if ( signal . rv < read_version ) {
768772 signal . rv = read_version ;
0 commit comments