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/short-jokes-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure props internally untracks current_value on sets
5 changes: 2 additions & 3 deletions packages/svelte/src/internal/client/reactivity/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ export function prop(props, key, flags, fallback) {
if (!immutable) current_value.equals = safe_equals;

return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
var current = get(current_value);

// legacy nonsense — need to ensure the source is invalidated when necessary
// also needed for when handling inspect logic so we can inspect the correct source signal
if (is_signals_recorded) {
Expand All @@ -398,11 +396,12 @@ export function prop(props, key, flags, fallback) {
if (fallback_used && fallback_value !== undefined) {
fallback_value = new_value;
}
get(current_value); // force a synchronisation immediately
untrack(() => get(current_value)); // force a synchronisation immediately
}

return value;
}
var current = get(current_value);

return current;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { flushSync } from 'svelte';
import { test } from '../../test';

export default test({
test({ assert, logs, target }) {
const btn = target.querySelector('button');

flushSync(() => {
btn?.click();
btn?.click();
btn?.click();
});

assert.deepEqual(logs, ['effect']);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
let {display = true} = $props();

$effect(()=>{
display = true;
console.log("effect")
});
</script>

<button onclick={() => display = !display} >display</button>