From ce72abcc47d172c168970679280d523ee56e029c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 14 Oct 2025 21:07:54 -0400 Subject: [PATCH] fix: update blocks that reference deriveds with `$state.eager` --- .../samples/async-state-eager-if/_config.js | 57 +++++++++++++++++++ .../samples/async-state-eager-if/main.svelte | 25 ++++++++ 2 files changed, 82 insertions(+) create mode 100644 packages/svelte/tests/runtime-runes/samples/async-state-eager-if/_config.js create mode 100644 packages/svelte/tests/runtime-runes/samples/async-state-eager-if/main.svelte diff --git a/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/_config.js b/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/_config.js new file mode 100644 index 0000000000..a1045ab363 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/_config.js @@ -0,0 +1,57 @@ +import { tick } from 'svelte'; +import { test } from '../../test'; + +export default test({ + mode: ['client'], + + compileOptions: { + dev: true + }, + + async test({ assert, target }) { + const [count, shift] = target.querySelectorAll('button'); + + shift.click(); + await tick(); + assert.htmlEqual(target.innerHTML, `

0

`); + + count.click(); + await tick(); + assert.htmlEqual( + target.innerHTML, + `

0

updating

` + ); + + count.click(); + await tick(); + assert.htmlEqual( + target.innerHTML, + `

0

updating

` + ); + + count.click(); + await tick(); + assert.htmlEqual( + target.innerHTML, + `

0

updating

` + ); + + shift.click(); + await tick(); + assert.htmlEqual( + target.innerHTML, + `

1

updating

` + ); + + shift.click(); + await tick(); + assert.htmlEqual( + target.innerHTML, + `

2

updating

` + ); + + shift.click(); + await tick(); + assert.htmlEqual(target.innerHTML, `

3

`); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/main.svelte b/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/main.svelte new file mode 100644 index 0000000000..5dee0c164d --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/async-state-eager-if/main.svelte @@ -0,0 +1,25 @@ + + + + + + +

{await push(count)}

+ + {#if count !== eager} +

updating

+ {/if} + + {#snippet pending()}{/snippet} +