File tree Expand file tree Collapse file tree 4 files changed +50
-6
lines changed
src/internal/client/dom/blocks
tests/runtime-runes/samples/non-error-boundary-preserve-on-error Expand file tree Collapse file tree 4 files changed +50
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: don't destroy contents of ` svelte:boundary ` unless the boundary is an error boundary
Original file line number Diff line number Diff line change @@ -285,6 +285,12 @@ export class Boundary {
285
285
var onerror = this . #props. onerror ;
286
286
let failed = this . #props. failed ;
287
287
288
+ // If we have nothing to capture the error, or if we hit an error while
289
+ // rendering the fallback, re-throw for another boundary to handle
290
+ if ( this . #is_creating_fallback || ( ! onerror && ! failed ) ) {
291
+ throw error ;
292
+ }
293
+
288
294
if ( this . #main_effect) {
289
295
destroy_effect ( this . #main_effect) ;
290
296
this . #main_effect = null ;
@@ -346,12 +352,6 @@ export class Boundary {
346
352
}
347
353
} ;
348
354
349
- // If we have nothing to capture the error, or if we hit an error while
350
- // rendering the fallback, re-throw for another boundary to handle
351
- if ( this . #is_creating_fallback || ( ! onerror && ! failed ) ) {
352
- throw error ;
353
- }
354
-
355
355
var previous_reaction = active_reaction ;
356
356
357
357
try {
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+ import { flushSync } from 'svelte' ;
3
+
4
+ export default test ( {
5
+ test ( { assert, target } ) {
6
+ const [ button ] = target . querySelectorAll ( 'button' ) ;
7
+
8
+ assert . throws ( ( ) => {
9
+ flushSync ( ( ) => button . click ( ) ) ;
10
+ } , / o o p s / ) ;
11
+
12
+ assert . htmlEqual (
13
+ target . innerHTML ,
14
+ `
15
+ <button>throw</button>
16
+ <p>some content</p>
17
+ `
18
+ ) ;
19
+ }
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script lang =" ts" >
2
+ let should_throw = $state (false );
3
+
4
+ function throw_error() {
5
+ throw new Error (' oops' );
6
+ }
7
+ </script >
8
+
9
+ <button onclick ={() => should_throw = true }>
10
+ throw
11
+ </button >
12
+
13
+ <svelte:boundary >
14
+ <p >some content</p >
15
+
16
+ {#if should_throw }
17
+ {throw_error ()}
18
+ {/if }
19
+ </svelte:boundary >
You can’t perform that action at this time.
0 commit comments