mirror of https://github.com/sveltejs/svelte
fix: make each items reassignable (#12257)
* chore: make each items reassignable * add failing test * update test * transform reassigned getters inside each block * Update .changeset/thirty-guests-flow.md * comment * add note * tidy up * Update packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.jsmain
parent
f81f4feab8
commit
9e511b141c
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: make each items reassignable in legacy mode
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
export let value;
|
||||
|
||||
value += 1;
|
||||
</script>
|
||||
|
||||
<p>{value}</p>
|
@ -0,0 +1,19 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<p>2, 3, 4</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
<p>4</p>
|
||||
<p>2, 3, 4</p>
|
||||
`,
|
||||
|
||||
ssrHtml: `
|
||||
<p>1, 2, 3</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
<p>4</p>
|
||||
<p>1, 2, 3</p>
|
||||
`
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Child from './Child.svelte';
|
||||
|
||||
let numbers = [1, 2, 3];
|
||||
</script>
|
||||
|
||||
<p>{numbers.join(', ')}</p>
|
||||
|
||||
{#each numbers as n}
|
||||
<Child bind:value={n} />
|
||||
{/each}
|
||||
|
||||
<p>{numbers.join(', ')}</p>
|
Loading…
Reference in new issue