fix: add `UNKNOWN` evaluation value before breaking for `binding.initial===SnippetBlock` (#16910)

pull/16909/head
Paolo Ricciuti 2 days ago committed by GitHub
parent edcd4b59e3
commit 1b1f144396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: add `UNKNOWN` evaluation value before breaking for `binding.initial===SnippetBlock`

@ -263,6 +263,7 @@ class Evaluation {
if (binding.initial?.type === 'SnippetBlock') { if (binding.initial?.type === 'SnippetBlock') {
this.is_defined = true; this.is_defined = true;
this.is_known = false; this.is_known = false;
this.values.add(UNKNOWN);
break; break;
} }

@ -0,0 +1,5 @@
<script>
let { test } = $props();
</script>
{@render test?.()}

@ -0,0 +1,10 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
async test({ assert, target }) {
const btn = target.querySelector('button');
flushSync(() => btn?.click());
assert.htmlEqual(target.innerHTML, `<button></button><p>snip</p>`);
}
});

@ -0,0 +1,15 @@
<script>
import Component from "./Component.svelte";
let count = $state(0);
</script>
{#snippet snip()}
<p>snip</p>
{/snippet}
<button onclick={() => count++}></button>
{#if true}
{@const test = count % 2 === 0 ? undefined: snip}
<Component {test} />
{/if}
Loading…
Cancel
Save