mirror of https://github.com/sveltejs/svelte
fix: invalidate `@const` tags based on visible references in legacy mode (#18041)
closes #17992pull/18043/head
parent
ff3495dc05
commit
edcbb0e640
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: invalidate `@const` tags based on visible references in legacy mode
|
||||
@ -0,0 +1,34 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<input>
|
||||
<p>hello</p>
|
||||
<p>hello</p>
|
||||
`,
|
||||
|
||||
ssrHtml: `
|
||||
<input value="hello">
|
||||
<p>hello</p>
|
||||
<p>hello</p>
|
||||
`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [input] = target.querySelectorAll('input');
|
||||
|
||||
flushSync(() => {
|
||||
input.value = 'goodbye';
|
||||
input.dispatchEvent(new InputEvent('input', { bubbles: true }));
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<input>
|
||||
<p>goodbye</p>
|
||||
<p>goodbye</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,15 @@
|
||||
<svelte:options runes={false} />
|
||||
|
||||
<script>
|
||||
let message = 'hello';
|
||||
</script>
|
||||
|
||||
<input bind:value={message} />
|
||||
|
||||
{#if true}
|
||||
{@const m1 = message}
|
||||
{@const m2 = (() => m1)()}
|
||||
|
||||
<p>{m1}</p>
|
||||
<p>{m2}</p>
|
||||
{/if}
|
||||
Loading…
Reference in new issue