mirror of https://github.com/sveltejs/svelte
fix: prevent nullish snippet for rendering empty content (#13083)
* fix: prevent nullish snippet for rendering empty content * fix: prevent nullish snippet for rendering empty content * lint * fix message * alternative approach * tweak * feedbackpull/13145/head
parent
e1448f22a3
commit
3b88b88886
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: prevent nullish snippet for rendering empty content
|
@ -0,0 +1,13 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target }) {
|
||||||
|
const btn = target.querySelector('button');
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
}, /invalid_snippet/);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let state = $state({
|
||||||
|
value: counter
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#snippet counter()}
|
||||||
|
Test
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
{@render state.value()}
|
||||||
|
|
||||||
|
<button onclick={() => state.value = undefined}>change</button>
|
Loading…
Reference in new issue