From 8bf08ff422dc663c54eddbc84af276d20d23e52d Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Fri, 20 Dec 2024 14:30:53 +0000 Subject: [PATCH] consistency fix 2 --- packages/svelte/src/internal/client/runtime.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index cbdbc26196..1db9c4abac 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -539,12 +539,13 @@ export function update_effect(effect) { execute_effect_teardown(effect); var teardown = update_reaction(effect); + var is_init = effect.version === 0; effect.teardown = typeof teardown === 'function' ? teardown : null; - // If unsafe() has been used within the effect, then we might need - // to schedule another update for this effect in case the unsafe mutation - // has caused a this effect to become invalidated again - if (unsafe_mutation_inside_effect && (effect.f & CLEAN) !== 0) { + // If unsafe() has been used within the effect on the first time + // it's run, then we might need to schedule the effect to run again + // if it has a dependency that has been invalidated + if (unsafe_mutation_inside_effect && is_init && (effect.f & CLEAN) !== 0) { set_signal_status(effect, MAYBE_DIRTY); if (check_dirtiness(effect)) { set_signal_status(effect, DIRTY);