File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ export function set(source, value) {
159159 return internal_set ( source , value ) ;
160160}
161161
162+ export const old_values = new Map ( ) ;
163+
162164/**
163165 * @template V
164166 * @param {Source<V> } source
@@ -167,6 +169,8 @@ export function set(source, value) {
167169 */
168170export function internal_set ( source , value ) {
169171 if ( ! source . equals ( value ) ) {
172+ old_values . set ( source , source . v ) ;
173+
170174 var old_value = source . v ;
171175 source . v = value ;
172176 source . wv = increment_write_version ( ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import {
2525 BOUNDARY_EFFECT
2626} from './constants.js' ;
2727import { flush_tasks } from './dom/task.js' ;
28- import { internal_set } from './reactivity/sources.js' ;
28+ import { internal_set , old_values } from './reactivity/sources.js' ;
2929import { destroy_derived_effects , update_derived } from './reactivity/deriveds.js' ;
3030import * as e from './errors.js' ;
3131import { FILENAME } from '../../constants.js' ;
@@ -673,6 +673,8 @@ function flush_queued_root_effects() {
673673 if ( DEV ) {
674674 dev_effect_stack = [ ] ;
675675 }
676+
677+ old_values . clear ( ) ;
676678 }
677679}
678680
@@ -923,6 +925,10 @@ export function get(signal) {
923925 }
924926 }
925927
928+ if ( is_destroying_effect && old_values . has ( signal ) ) {
929+ return old_values . get ( signal ) ;
930+ }
931+
926932 return signal . v ;
927933}
928934
You can’t perform that action at this time.
0 commit comments