fix: ensure props internally untracks current_value on sets (#13859)

* fix: ensure props internally untracks current_value on sets

* Update packages/svelte/src/internal/client/reactivity/props.js

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
pull/13870/head
Dominic Gannaway 11 months ago committed by GitHub
parent 60dcffb856
commit 4fbd2a6f10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure props internally untracks current_value on sets

@ -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) {
@ -398,12 +396,11 @@ 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;
}
return current;
return get(current_value);
};
}

@ -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']);
}
});

@ -0,0 +1,10 @@
<script>
let {display = true} = $props();
$effect(()=>{
display = true;
console.log("effect")
});
</script>
<button onclick={() => display = !display} >display</button>
Loading…
Cancel
Save