mirror of https://github.com/sveltejs/svelte
fix: use safe-equals comparison for `@const` tags in legacy mode (#10606)
fixes #10600pull/10608/head
parent
c10337cfb2
commit
db0b802fc2
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: use safe-equals comparison for `@const` tags in legacy mode
|
@ -0,0 +1,29 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
// Test ensures that the `const` tag is coarse-grained in legacy mode (i.e. always fires an update when the array changes)
|
||||
export default test({
|
||||
html: `
|
||||
<button>Show</button>
|
||||
<p>0</p>
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
`,
|
||||
async test({ target, assert }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
await tick();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>Show</button>
|
||||
<p>0 show (v_item) show (item)</p>
|
||||
<p>1</p>
|
||||
<p>2 show (v_item) show (item)</p>
|
||||
<p>3</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
export let items = {0:{clicked:false},length:4};
|
||||
</script>
|
||||
|
||||
<button on:click={()=>{
|
||||
items[0].clicked=true;
|
||||
items[2]={clicked:true};
|
||||
}}>Show</button>
|
||||
|
||||
{#each items as item, i}
|
||||
{@const v_item=item}
|
||||
<p>
|
||||
{i}
|
||||
{#if v_item?.clicked}
|
||||
show (v_item)
|
||||
{/if}
|
||||
{#if item?.clicked}
|
||||
show (item)
|
||||
{/if}
|
||||
</p>
|
||||
{/each}
|
Loading…
Reference in new issue