Skip to content

Commit b213de2

Browse files
committed
Update comment
1 parent 5ed74b2 commit b213de2

File tree

1 file changed

+6
-2
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ export function update_derived(derived) {
185185
// that also happens before user_effect teardown.
186186
//
187187
// store old value only if not inside a teardown function
188-
// because in legacy mode, bindable props are deriveds
189-
// and they are executed during teardown.
188+
// because we only need to save the old values before
189+
// the cleanup is triggered othewise accessing
190+
// a derived during cleanup will return the incorrect
191+
// value in case the derived wasn't in the deps of the effect,
192+
// or the teardown was executed because the component was
193+
// destroyed.
190194
if (!is_destroying_effect) {
191195
var old_value = derived.v;
192196
old_values.set(derived, old_value);

0 commit comments

Comments
 (0)