Skip to content

Commit 209f311

Browse files
committed
reduce indirection
1 parent 964004a commit 209f311

File tree

1 file changed

+19
-3
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+19
-3
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function boundary(node, props, boundary_fn) {
106106

107107
if (input === SUSPEND_INCREMENT) {
108108
if (!pending) {
109+
// TODO in this case we need to find the parent boundary
109110
return false;
110111
}
111112

@@ -150,6 +151,7 @@ export function boundary(node, props, boundary_fn) {
150151

151152
if (input === SUSPEND_DECREMENT) {
152153
if (!pending) {
154+
// TODO in this case we need to find the parent boundary
153155
return false;
154156
}
155157

@@ -268,9 +270,21 @@ export async function preserve_context(promise) {
268270
var previous_reaction = active_reaction;
269271
var previous_component_context = component_context;
270272

271-
const [suspend, unsuspend] = create_suspense();
273+
let boundary = active_effect;
274+
while (boundary !== null) {
275+
if ((boundary.f & BOUNDARY_EFFECT) !== 0) {
276+
break;
277+
}
278+
279+
boundary = boundary.parent;
280+
}
272281

273-
suspend();
282+
if (boundary === null) {
283+
throw new Error('cannot suspend outside a boundary');
284+
}
285+
286+
// @ts-ignore
287+
boundary.fn(SUSPEND_INCREMENT);
274288

275289
const value = await promise;
276290

@@ -280,7 +294,9 @@ export async function preserve_context(promise) {
280294
set_active_reaction(previous_reaction);
281295
set_component_context(previous_component_context);
282296

283-
unsuspend();
297+
// @ts-ignore
298+
boundary.fn(SUSPEND_DECREMENT);
299+
284300
return value;
285301
}
286302
};

0 commit comments

Comments
 (0)