mirror of https://github.com/sveltejs/svelte
fix: error on `bind:this` to each block parameter (#12638)
* chore: remove outdated comment * fix: error on `bind:this` to each block parameterpull/12641/head
parent
7af0e604d8
commit
219ba6a71b
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: error on `bind:this` to each block parameter
|
@ -0,0 +1,9 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
error: {
|
||||||
|
code: 'each_item_invalid_assignment',
|
||||||
|
message:
|
||||||
|
'Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)'
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let array: Array<{ id: number; element: HTMLElement | null }> = $state([
|
||||||
|
{ id: 1, element: null },
|
||||||
|
{ id: 2, element: null },
|
||||||
|
{ id: 3, element: null }
|
||||||
|
]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each array as { id, element } (id)}
|
||||||
|
<input bind:this={element} />
|
||||||
|
{/each}
|
Loading…
Reference in new issue