mirror of https://github.com/sveltejs/svelte
Merge 3624db9d01 into fa4f1c45f4
commit
588573319b
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
Fixed `bind:` not working in `{#each}` blocks when the expression is a `$derived` that references a store (e.g. `{#each $derived($store) as item}`). The compiler now traces through derived bindings to detect underlying store subscriptions, ensuring proper store invalidation and mutable item tracking.
|
||||
@ -0,0 +1,25 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { ok, test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<input> <p>initial</p>`,
|
||||
ssrHtml: `<input value="initial"> <p>initial</p>`,
|
||||
|
||||
test({ assert, target, window }) {
|
||||
const input = target.querySelector('input');
|
||||
ok(input);
|
||||
|
||||
const event = new window.Event('input');
|
||||
input.value = 'changed';
|
||||
input.dispatchEvent(event);
|
||||
flushSync();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<input>
|
||||
<p>changed</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
const store = writable([{ text: 'initial' }]);
|
||||
const items = $derived($store);
|
||||
</script>
|
||||
|
||||
{#each items as item}
|
||||
<input bind:value={item.text} />
|
||||
{/each}
|
||||
|
||||
<p>{items[0].text}</p>
|
||||
Loading…
Reference in new issue