Skip to content

Commit f584d0d

Browse files
committed
fix
1 parent fcd51d4 commit f584d0d

File tree

1 file changed

+9
-4
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+9
-4
lines changed

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ export class Batch {
6161
process(root_effects) {
6262
set_queued_root_effects([]);
6363

64+
/** @type {Map<Source, { v: unknown, wv: number }>} */
6465
var current_values = new Map();
6566

6667
for (const [source, current] of this.#current) {
67-
current_values.set(source, source.v);
68+
current_values.set(source, { v: source.v, wv: source.wv });
6869
source.v = current;
6970
}
7071

@@ -73,7 +74,7 @@ export class Batch {
7374

7475
for (const [source, previous] of batch.#previous) {
7576
if (!current_values.has(source)) {
76-
current_values.set(source, source.v);
77+
current_values.set(source, { v: source.v, wv: source.wv });
7778
source.v = previous;
7879
}
7980
}
@@ -101,8 +102,12 @@ export class Batch {
101102
for (const e of this.effects) set_signal_status(e, CLEAN);
102103
}
103104

104-
for (const [source, value] of current_values) {
105-
source.v = value;
105+
for (const [source, { v, wv }] of current_values) {
106+
// reset the source to the current value (unless
107+
// it got a newer value as a result of effects running)
108+
if (source.wv <= wv) {
109+
source.v = v;
110+
}
106111
}
107112

108113
for (const effect of this.async_effects) {

0 commit comments

Comments
 (0)