Skip to content

Commit

Permalink
Merge branch 'experiment_s' into aa
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 15, 2025
2 parents e2bc4d9 + c7d3af1 commit 2cd6b73
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions packages/svelte/src/internal/client/dom/blocks/boundary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @import { Effect, TemplateNode, } from '#client' */

import { BOUNDARY_EFFECT, EFFECT_TRANSPARENT, INERT } from '../../constants.js';
import { BOUNDARY_EFFECT, EFFECT_TRANSPARENT } from '../../constants.js';
import {
block,
branch,
Expand Down Expand Up @@ -81,22 +81,19 @@ export function boundary(node, props, boundary_fn) {
var is_creating_fallback = false;

const render_snippet = (/** @type { () => void } */ snippet_fn) => {
// Render the snippet in a microtask
queue_micro_task(() => {
with_boundary(boundary, () => {
is_creating_fallback = true;
with_boundary(boundary, () => {
is_creating_fallback = true;

try {
boundary_effect = branch(() => {
snippet_fn();
});
} catch (error) {
handle_error(error, boundary, null, boundary.ctx);
}
try {
boundary_effect = branch(() => {
snippet_fn();
});
} catch (error) {
handle_error(error, boundary, null, boundary.ctx);
}

reset_is_throwing_error();
is_creating_fallback = false;
});
reset_is_throwing_error();
is_creating_fallback = false;
});
};

Expand Down Expand Up @@ -160,7 +157,6 @@ export function boundary(node, props, boundary_fn) {
if (!suspended_effect) {
return;
}

if (boundary_effect) {
destroy_effect(boundary_effect);
}
Expand Down Expand Up @@ -205,12 +201,14 @@ export function boundary(node, props, boundary_fn) {
}

if (failed) {
render_snippet(() => {
failed(
anchor,
() => error,
() => reset
);
queue_micro_task(() => {
render_snippet(() => {
failed(
anchor,
() => error,
() => reset
);
});
});
}
};
Expand Down

0 comments on commit 2cd6b73

Please sign in to comment.