fix context stuff

pull/16748/head
Rich Harris 11 months ago
parent eb33a2f8e9
commit 3681767f56

@ -75,11 +75,11 @@ export function pop() {
}
/**
* @param {SSRContext} component_context
* @param {SSRContext} ssr_context
* @returns {Map<unknown, unknown> | null}
*/
function get_parent_context(component_context) {
let parent = component_context.p;
function get_parent_context(ssr_context) {
let parent = ssr_context.p;
while (parent !== null) {
const context_map = parent.c;

@ -86,7 +86,7 @@ export function push_element(payload, tag, line, column) {
}
export function pop_element() {
set_ssr_context(ssr_context?.p ?? null);
set_ssr_context(/** @type {SSRContext} */ (ssr_context).p);
}
/**

@ -100,15 +100,19 @@ export class Payload {
const child = new Payload(this.global, this, type);
this.#out.push(child);
const parent = ssr_context;
set_ssr_context({
...ssr_context,
p: ssr_context?.p ?? null,
c: ssr_context?.c ?? null,
p: parent,
c: null,
r: child
});
const result = fn(child);
set_ssr_context(parent);
if (result instanceof Promise) {
if (child.global.mode === 'sync') {
e.await_invalid();

Loading…
Cancel
Save