Skip to content

Commit e6cd426

Browse files
committed
wip
1 parent a4bf5e3 commit e6cd426

File tree

3 files changed

+47
-37
lines changed

3 files changed

+47
-37
lines changed

packages/svelte/src/index-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,4 @@ export {
192192

193193
export { createRawSnippet } from './internal/client/dom/blocks/snippet.js';
194194

195-
export { suspend, unsuspend } from './internal/client/dom/blocks/boundary.js';
195+
export { create_suspense } from './internal/client/dom/blocks/boundary.js';

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

+45-35
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,34 @@ export function boundary(node, props, boundary_fn) {
111111
suspend_count++;
112112

113113
if (suspended_effect === null) {
114-
var effect = boundary_effect;
115-
suspended_effect = boundary_effect;
116-
117-
pause_effect(suspended_effect, () => {
118-
/** @type {TemplateNode | null} */
119-
var node = effect.nodes_start;
120-
var end = effect.nodes_end;
121-
suspended_fragment = document.createDocumentFragment();
122-
123-
while (node !== null) {
124-
/** @type {TemplateNode | null} */
125-
var sibling =
126-
node === end ? null : /** @type {TemplateNode} */ (get_next_sibling(node));
127-
128-
node.remove();
129-
suspended_fragment.append(node);
130-
node = sibling;
131-
}
132-
}, false);
133-
134-
render_snippet(() => {
135-
pending(anchor);
114+
queue_micro_task(() => {
115+
var effect = boundary_effect;
116+
suspended_effect = boundary_effect;
117+
118+
pause_effect(
119+
suspended_effect,
120+
() => {
121+
/** @type {TemplateNode | null} */
122+
var node = effect.nodes_start;
123+
var end = effect.nodes_end;
124+
suspended_fragment = document.createDocumentFragment();
125+
126+
while (node !== null) {
127+
/** @type {TemplateNode | null} */
128+
var sibling =
129+
node === end ? null : /** @type {TemplateNode} */ (get_next_sibling(node));
130+
131+
node.remove();
132+
suspended_fragment.append(node);
133+
node = sibling;
134+
}
135+
},
136+
false
137+
);
138+
139+
render_snippet(() => {
140+
pending(anchor);
141+
});
136142
});
137143
}
138144
return true;
@@ -211,30 +217,34 @@ export function boundary(node, props, boundary_fn) {
211217
}
212218
}
213219

214-
export function suspend() {
215-
var current = active_effect;
220+
/**
221+
* @param {Effect | null} effect
222+
* @param {typeof SUSPEND_INCREMENT | typeof SUSPEND_DECREMENT} trigger
223+
*/
224+
function trigger_suspense(effect, trigger) {
225+
var current = effect;
216226

217227
while (current !== null) {
218228
if ((current.f & BOUNDARY_EFFECT) !== 0) {
219229
// @ts-ignore
220-
if (current.fn(SUSPEND_INCREMENT)) {
230+
if (current.fn(trigger)) {
221231
return;
222232
}
223233
}
224234
current = current.parent;
225235
}
226236
}
227237

228-
export function unsuspend() {
238+
export function create_suspense() {
229239
var current = active_effect;
230240

231-
while (current !== null) {
232-
if ((current.f & BOUNDARY_EFFECT) !== 0) {
233-
// @ts-ignore
234-
if (current.fn(SUSPEND_DECREMENT)) {
235-
return;
236-
}
237-
}
238-
current = current.parent;
239-
}
241+
const suspend = () => {
242+
trigger_suspense(current, SUSPEND_INCREMENT);
243+
};
244+
245+
const unsuspend = () => {
246+
trigger_suspense(current, SUSPEND_DECREMENT);
247+
};
248+
249+
return [suspend, unsuspend];
240250
}

packages/svelte/src/internal/client/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export {
129129
update_store,
130130
mark_store_binding
131131
} from './reactivity/store.js';
132-
export { boundary, suspend } from './dom/blocks/boundary.js';
132+
export { boundary } from './dom/blocks/boundary.js';
133133
export { set_text } from './render.js';
134134
export {
135135
get,

0 commit comments

Comments
 (0)