Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nervous-kids-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: set deriveds as `CLEAN` if they are assigned to
4 changes: 4 additions & 0 deletions packages/svelte/src/internal/client/reactivity/sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export function internal_set(source, value) {
}
}

if ((source.f & DERIVED) !== 0) {
set_signal_status(/** @type {Derived} */ (source), CLEAN);
}

mark_reactions(source, DIRTY);

// It's possible that the current reaction might not have up-to-date dependencies
Expand Down
15 changes: 15 additions & 0 deletions packages/svelte/tests/signals/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,21 @@ describe('signals', () => {
};
});

test.only("deriveds set after they are DIRTY doesn't get updated on get", () => {
return () => {
const a = state(0);
const b = derived(() => $.get(a));

set(b, 1);
assert.equal($.get(b), 1);

set(a, 2);
set(b, 3);

assert.equal($.get(b), 3);
};
});

test('deriveds containing effects work correctly when used with untrack', () => {
return () => {
let a = render_effect(() => {});
Expand Down
Loading