-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tweak tweak tweak more fixes tweak tweak more fixes changeset
- Loading branch information
Showing
9 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
feat: adds error boundaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/runtime-runes/samples/error-boundary-12/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, target, logs }) { | ||
const btn = target.querySelector('button'); | ||
|
||
btn?.click(); | ||
flushSync(); | ||
|
||
assert.htmlEqual(target.innerHTML, `<button>change</button><p>Error occured</p>`); | ||
} | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/svelte/tests/runtime-runes/samples/error-boundary-12/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script> | ||
let count = $state(0); | ||
const things = $derived.by(() => { | ||
if (count === 1) { | ||
throw new Error('123') | ||
} | ||
return [1, 2 ,3] | ||
}) | ||
</script> | ||
|
||
<button onclick={() => count++}>change</button> | ||
|
||
<svelte:boundary> | ||
{#each things as thing} | ||
<p>{thing}</p> | ||
{/each} | ||
|
||
{#snippet failed()} | ||
<p>Error occured</p> | ||
{/snippet} | ||
</svelte:boundary> |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/error-boundary-13/Child.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
const { things } = $props(); | ||
$effect(() => { | ||
things | ||
}) | ||
</script> |
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/runtime-runes/samples/error-boundary-13/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, target, logs }) { | ||
const btn = target.querySelector('button'); | ||
|
||
btn?.click(); | ||
flushSync(); | ||
|
||
assert.htmlEqual(target.innerHTML, `<button>change</button><p>Error occured</p>`); | ||
} | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/svelte/tests/runtime-runes/samples/error-boundary-13/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script> | ||
import Child from './Child.svelte'; | ||
let count = $state(0); | ||
const things = $derived.by(() => { | ||
if (count === 1) { | ||
throw new Error('123') | ||
} | ||
return [1, 2 ,3] | ||
}) | ||
</script> | ||
|
||
<button onclick={() => count++}>change</button> | ||
|
||
<svelte:boundary> | ||
<Child {things} /> | ||
|
||
{#snippet failed()} | ||
<p>Error occured</p> | ||
{/snippet} | ||
</svelte:boundary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters