Skip to content

Commit

Permalink
fix: reset dependency read versions after reaction execution
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Jan 9, 2025
1 parent 0168c34 commit d172aac
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,24 @@ export function update_reaction(reaction) {
reaction.deps = deps = new_deps;
}

for (i = skipped_deps; i < deps.length; i++) {
var dep = deps[i];
if (!skip_reaction) {
(dep.reactions ??= []).push(reaction);
if (!skip_reaction) {
for (i = skipped_deps; i < deps.length; i++) {
(deps[i].reactions ??= []).push(reaction);
}
// Reset read version back to 0. If we are
// returning to an previous reaction and
// it were to read this depedency too and we
// didn't reset the read version, then it would
// not be added as a dependency to that reaction
// as the global read version won't have changed
dep.rv = 0;
}
} else if (deps !== null && skipped_deps < deps.length) {
remove_reactions(reaction, skipped_deps);
deps.length = skipped_deps;
}

// If we are returning to an previous reaction then
// we need to increment the read version to ensure that
// any dependencies in this reaction aren't marked with
// the same version
if (previous_reaction !== null) {
read_version++;
}

return result;
} finally {
new_deps = previous_deps;
Expand Down

0 comments on commit d172aac

Please sign in to comment.