mirror of https://github.com/sveltejs/svelte
fix: reset dependency read versions after reaction execution (#14964)
* fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * fix: reset dependency read versions after reaction execution * chore: add test * changeset --------- Co-authored-by: paoloricciuti <ricciutipaolo@gmail.com> Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/14965/head
parent
b7400ae93b
commit
bdc02008e4
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: reset dependency read versions after reaction execution
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
const { label = 0, size = 0 } = $props();
|
||||
|
||||
const title = $derived(size.toString());
|
||||
</script>
|
||||
|
||||
<p {title}>{label}</p>
|
@ -0,0 +1,19 @@
|
||||
import { ok, test } from '../../test';
|
||||
import { flushSync } from 'svelte';
|
||||
|
||||
export default test({
|
||||
html: `<button></button><p title="0">0</p>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const p = target.querySelector('p');
|
||||
const btn = target.querySelector('button');
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.equal(p?.innerHTML, '1');
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
assert.equal(p?.innerHTML, '2');
|
||||
}
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
import Component from "./Component.svelte";
|
||||
|
||||
let props = $state({
|
||||
label: 0,
|
||||
size: 0,
|
||||
});
|
||||
|
||||
let filteredProps = $state();
|
||||
|
||||
$effect.pre(() => {
|
||||
filteredProps = $state.snapshot(props);
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={()=>props.label++}></button>
|
||||
|
||||
<Component {...filteredProps} />
|
Loading…
Reference in new issue