Skip to content

Commit 58905d5

Browse files
committed
tweaks
1 parent 48939c5 commit 58905d5

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ export function SvelteBoundary(node, context) {
7979
const props_expression =
8080
!has_spread && Array.isArray(props_and_spreads[0])
8181
? b.object(props_and_spreads[0])
82-
: b.call(
83-
'$.spread_props',
84-
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
85-
);
82+
: props_and_spreads.length === 0
83+
? b.object([])
84+
: b.call(
85+
'$.spread_props',
86+
...props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p))
87+
);
8688

8789
const boundary = b.stmt(
8890
b.call('$.boundary', context.state.node, b.arrow([b.id('$$anchor')], block), props_expression)

packages/svelte/src/internal/client/dom/blocks/boundary.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export function boundary(node, boundary_fn, props) {
7171
var onerror = props.onerror;
7272
let failed_snippet = props.failed;
7373

74+
if (boundary_effect) {
75+
destroy_effect(boundary_effect);
76+
}
77+
7478
// If we have nothing to capture the error then rethrow the error
7579
// for another boundary to handle
7680
if (!onerror && !failed_snippet) {
@@ -88,10 +92,12 @@ export function boundary(node, boundary_fn, props) {
8892
});
8993
};
9094

95+
// Handle the `onerror` event handler
9196
if (onerror) {
9297
onerror(error, reset);
9398
}
9499

100+
// Handle the `failed` snippet fallback
95101
if (failed_snippet) {
96102
// Ensure we create the boundary branch after the catch event cycle finishes
97103
queue_micro_task(() => {
@@ -107,17 +113,6 @@ export function boundary(node, boundary_fn, props) {
107113
});
108114
});
109115
}
110-
111-
// If there was an error then we'll need to remove the current content
112-
// that was SSR'd
113-
if (hydrating) {
114-
set_hydrate_node(/** @type {TemplateNode} */ (start.nextSibling));
115-
var hydration_node = remove_nodes();
116-
set_hydrate_node(hydration_node);
117-
}
118-
if (boundary_effect) {
119-
destroy_effect(boundary_effect);
120-
}
121116
};
122117

123118
if (hydrating) {

0 commit comments

Comments
 (0)