@@ -87,17 +87,17 @@ export function set_active_effect(effect) {
8787/**
8888 * When sources are created within a reaction, reading and writing
8989 * them within that reaction should not cause a re-run
90- * @type {null | { reaction: Reaction, sources: Source[] } }
90+ * @type {null | Source[] }
9191 */
92- export let source_ownership = null ;
92+ export let current_sources = null ;
9393
9494/** @param {Value } value */
9595export function push_reaction_value ( value ) {
9696 if ( active_reaction !== null && ( ! async_mode_flag || ( active_reaction . f & DERIVED ) !== 0 ) ) {
97- if ( source_ownership === null ) {
98- source_ownership = { reaction : active_reaction , sources : [ value ] } ;
97+ if ( current_sources === null ) {
98+ current_sources = [ value ] ;
9999 } else {
100- source_ownership . sources . push ( value ) ;
100+ current_sources . push ( value ) ;
101101 }
102102 }
103103}
@@ -135,6 +135,11 @@ let read_version = 0;
135135
136136export let update_version = read_version ;
137137
138+ /** @param {number } value */
139+ export function set_update_version ( value ) {
140+ update_version = value ;
141+ }
142+
138143// If we are working with a get() chain that has no active container,
139144// to prevent memory leaks, we skip adding the reaction.
140145export let skip_reaction = false ;
@@ -239,11 +244,7 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
239244 var reactions = signal . reactions ;
240245 if ( reactions === null ) return ;
241246
242- if (
243- ! async_mode_flag &&
244- source_ownership ?. reaction === active_reaction &&
245- source_ownership . sources . includes ( signal )
246- ) {
247+ if ( ! async_mode_flag && current_sources ?. includes ( signal ) ) {
247248 return ;
248249 }
249250
@@ -270,7 +271,7 @@ export function update_reaction(reaction) {
270271 var previous_untracked_writes = untracked_writes ;
271272 var previous_reaction = active_reaction ;
272273 var previous_skip_reaction = skip_reaction ;
273- var previous_reaction_sources = source_ownership ;
274+ var previous_sources = current_sources ;
274275 var previous_component_context = component_context ;
275276 var previous_untracking = untracking ;
276277 var previous_update_version = update_version ;
@@ -284,7 +285,7 @@ export function update_reaction(reaction) {
284285 ( flags & UNOWNED ) !== 0 && ( untracking || ! is_updating_effect || active_reaction === null ) ;
285286 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
286287
287- source_ownership = null ;
288+ current_sources = null ;
288289 set_component_context ( reaction . ctx ) ;
289290 untracking = false ;
290291 update_version = ++ read_version ;
@@ -376,7 +377,7 @@ export function update_reaction(reaction) {
376377 untracked_writes = previous_untracked_writes ;
377378 active_reaction = previous_reaction ;
378379 skip_reaction = previous_skip_reaction ;
379- source_ownership = previous_reaction_sources ;
380+ current_sources = previous_sources ;
380381 set_component_context ( previous_component_context ) ;
381382 untracking = previous_untracking ;
382383 update_version = previous_update_version ;
@@ -550,10 +551,7 @@ export function get(signal) {
550551 // we don't add the dependency, because that would create a memory leak
551552 var destroyed = active_effect !== null && ( active_effect . f & DESTROYED ) !== 0 ;
552553
553- var is_owned_by_reaction =
554- source_ownership ?. reaction === active_reaction && source_ownership . sources . includes ( signal ) ;
555-
556- if ( ! destroyed && ! is_owned_by_reaction ) {
554+ if ( ! destroyed && ! current_sources ?. includes ( signal ) ) {
557555 var deps = active_reaction . deps ;
558556
559557 if ( ( active_reaction . f & REACTION_IS_UPDATING ) !== 0 ) {
0 commit comments