update test

proxied-state-each-blocks
Rich Harris 1 year ago committed by Dominic Gannaway
parent 8a2e94163d
commit 5f8988ad73

@ -4,7 +4,7 @@ export default test({
html: ` html: `
<button>foo</button> <button>foo</button>
<button>foo</button> <button>foo</button>
<button>foo</button> <button>FOO</button>
`, `,
async test({ assert, target }) { async test({ assert, target }) {
@ -25,7 +25,7 @@ export default test({
` `
<button>bar</button> <button>bar</button>
<button>bar</button> <button>bar</button>
<button>foo</button> <button>BAR</button>
` `
); );
} }

@ -1,20 +1,20 @@
<script> <script>
let works1 = $state([{ text: 'foo' }]); let a = $state([{ text: 'foo' }]);
let b = $state([{ text: 'foo' }]);
let text = $state('foo'); let text = $state('foo');
let works2 = $state([{ get text() { return text }, set text(v) { text = v }}]); let c = $state([{ get text() { return text.toUpperCase() }, set text(v) { text = v }}]);
let doesntwork = $state([{ text: 'foo' }]);
</script> </script>
{#each works1 as item, i} {#each a as item, i}
<button on:click={() => works1[i].text = 'bar'}>{item.text}</button> <button on:click={() => a[i].text = 'bar'}>{item.text}</button>
{/each} {/each}
{#each works2 as item} {#each b as item}
<button on:click={() => item.text = 'bar'}>{item.text}</button> <button on:click={() => item.text = 'bar'}>{item.text}</button>
{/each} {/each}
{#each doesntwork as item} {#each c as item}
<button on:click={() => item.text = 'bar'}>{item.text}</button> <button on:click={() => item.text = 'bar'}>{item.text}</button>
{/each} {/each}

Loading…
Cancel
Save