update test

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

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

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

Loading…
Cancel
Save