MCPcopy
hub / github.com/sveltejs/svelte / child

Method child

packages/svelte/src/internal/server/renderer.js:201–231  ·  view source on GitHub ↗

* Create a child renderer. The child renderer inherits the state from the parent, * but has its own content. * @param {(renderer: Renderer) => MaybePromise<void>} fn

(fn)

Source from the content-addressed store, hash-verified

199 * @param {(renderer: Renderer) => MaybePromise<void>} fn
200 */
201 child(fn) {
202 const child = new Renderer(this.global, this);
203 this.#out.push(child);
204
205 const parent = ssr_context;
206
207 set_ssr_context({
208 ...ssr_context,
209 p: parent,
210 c: null,
211 r: child
212 });
213
214 const result = fn(child);
215
216 set_ssr_context(parent);
217
218 if (result instanceof Promise) {
219 // catch to avoid unhandled promise rejections - we'll end up throwing in `collect_async` if something fails
220 result.catch(noop);
221 result.finally(() => set_ssr_context(null)).catch(noop);
222
223 if (child.global.mode === 'sync') {
224 e.await_invalid();
225 }
226
227 child.promise = result;
228 }
229
230 return child;
231 }
232
233 /**
234 * Render children inside an error boundary. If the children throw and the API-level

Callers 12

headMethod · 0.95
asyncMethod · 0.95
child_blockMethod · 0.95
componentMethod · 0.95
selectMethod · 0.95
optionMethod · 0.95
titleMethod · 0.95
pushMethod · 0.95
headFunction · 0.45
componentFunction · 0.45
componentFunction · 0.45
renderer.test.tsFile · 0.45

Calls 3

set_ssr_contextFunction · 0.90
pushMethod · 0.80
fnFunction · 0.50

Tested by 2

componentFunction · 0.36
componentFunction · 0.36