fix: improve internal_set versioning mechanic (#15724)

pull/15730/head
Dominic Gannaway 5 months ago committed by GitHub
parent c2c83b67f3
commit 9cafdd89d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: improve internal_set versioning mechanic

@ -162,7 +162,6 @@ export function internal_set(source, value) {
} }
source.v = value; source.v = value;
source.wv = increment_write_version();
if (DEV && tracing_mode_flag) { if (DEV && tracing_mode_flag) {
source.updated = get_stack('UpdatedAt'); source.updated = get_stack('UpdatedAt');
@ -180,6 +179,8 @@ export function internal_set(source, value) {
set_signal_status(source, (source.f & UNOWNED) === 0 ? CLEAN : MAYBE_DIRTY); set_signal_status(source, (source.f & UNOWNED) === 0 ? CLEAN : MAYBE_DIRTY);
} }
source.wv = increment_write_version();
mark_reactions(source, DIRTY); mark_reactions(source, DIRTY);
// It's possible that the current reaction might not have up-to-date dependencies // It's possible that the current reaction might not have up-to-date dependencies

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
html: `true true`,
test({ assert, target, window }) {}
});

@ -0,0 +1,9 @@
<script>
import { expect2, createAppState } from "./util.svelte.js"
const result = createAppState({ source: () => "wrong" });
result.onChange("right");
const expect1 = result.value === "right";
</script>
{expect1} {expect2}

@ -0,0 +1,17 @@
export const createAppState = (options) => {
const source = $derived(options.source());
let value = $derived(source);
return {
get value() {
return value;
},
onChange(nextValue) {
value = nextValue;
}
};
};
const result = createAppState({ source: () => 'wrong' });
result.onChange('right');
export const expect2 = result.value === 'right';
Loading…
Cancel
Save