mirror of https://github.com/sveltejs/svelte
fix: ensure each blocks properly handle $state.frozen objects in prod (#12305)
* fix: ensure each blocks properly handle $state.frozen objects in prod * fix: ensure each blocks properly handle $state.frozen objects in prodpull/12282/head
parent
bc32b7c828
commit
15a8518b91
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure each blocks properly handle $state.frozen objects in prod
|
@ -0,0 +1,19 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
// TODO: need to force DEV to be false for runtime somehow
|
||||
async test({ assert, target, logs }) {
|
||||
const [btn1] = target.querySelectorAll('button');
|
||||
|
||||
assert.equal(logs.length, 3);
|
||||
|
||||
logs.length = 0;
|
||||
|
||||
flushSync(() => {
|
||||
btn1.click();
|
||||
});
|
||||
|
||||
assert.equal(logs.length, 1);
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let frozen_items = $state.frozen([
|
||||
{id: 0, text: 'a'},
|
||||
{id: 1, text: 'b'},
|
||||
{id: 2, text: 'c'}
|
||||
])
|
||||
</script>
|
||||
|
||||
{#each frozen_items as item (item.id)}
|
||||
{console.log(item.text)}
|
||||
{item.text}
|
||||
{/each}
|
||||
|
||||
<button onclick={() => {
|
||||
frozen_items = [...frozen_items, {id: 3, text: 'd'}]
|
||||
}}></button>
|
Loading…
Reference in new issue