mirror of https://github.com/sveltejs/svelte
fix: capture infinite_loop_guard in error boundary (#14534)
* fix: capture infinite_loop_guard in error boundary * fixpull/14537/head
parent
d5a28a01a1
commit
b5588523fc
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: capture infinite_loop_guard in error boundary
|
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
let clicked = $state(false);
|
||||
|
||||
function increment() {
|
||||
clicked = true;
|
||||
count++;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (clicked) {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={increment}>{count}</button>
|
@ -0,0 +1,13 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target }) {
|
||||
let btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
flushSync();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<div class="error">An error occurred!</div>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import Child from "./Child.svelte"
|
||||
</script>
|
||||
<svelte:boundary>
|
||||
<Child />
|
||||
|
||||
{#snippet failed()}
|
||||
<div class="error">An error occurred!</div>
|
||||
{/snippet}
|
||||
</svelte:boundary>
|
Loading…
Reference in new issue