Skip to content

Commit 14ca327

Browse files
committed
don't self-invalidate when updating a source create inside current reaction
1 parent ec1b7d8 commit 14ca327

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ export function set(source, value, should_proxy = false) {
154154
!untracking &&
155155
is_runes() &&
156156
(active_reaction.f & (DERIVED | BLOCK_EFFECT)) !== 0 &&
157-
// If the source was created locally within the current derived, then
158-
// we allow the mutation.
159-
(derived_sources === null || !derived_sources.includes(source))
157+
active_reaction !== source.parent
160158
) {
161159
e.state_unsafe_mutation();
162160
}

packages/svelte/src/internal/client/runtime.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ function schedule_possible_effect_self_invalidation(signal, effect, root = true)
367367

368368
for (var i = 0; i < reactions.length; i++) {
369369
var reaction = reactions[i];
370+
if (signal.parent === reaction) continue;
371+
370372
if ((reaction.f & DERIVED) !== 0) {
371373
schedule_possible_effect_self_invalidation(/** @type {Derived} */ (reaction), effect, false);
372374
} else if (effect === reaction) {

0 commit comments

Comments
 (0)