Skip to content

Commit 0aae872

Browse files
committed
hmm
1 parent a7282c9 commit 0aae872

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,15 @@ export function client_component(analysis, options) {
455455
// we want the cleanup function for the stores to run as the very last thing
456456
// so that it can effectively clean up the store subscription even after the user effects runs
457457
if (should_inject_context) {
458-
component_block.body.unshift(b.stmt(b.call('$.push', ...push_args)));
458+
component_block.body.unshift(b.var('$$component', b.call('$.push', ...push_args)));
459459

460460
let to_push;
461461

462462
if (component_returned_object.length > 0) {
463-
let pop_call = b.call('$.pop', b.id('$$exports'));
463+
let pop_call = b.call('$.pop', b.id('$$component'), b.id('$$exports'));
464464
to_push = needs_store_cleanup ? b.var('$$pop', pop_call) : b.return(pop_call);
465465
} else {
466-
to_push = b.stmt(b.call('$.pop'));
466+
to_push = b.stmt(b.call('$.pop', b.id('$$component')));
467467
}
468468

469469
component_block.body.push(to_push);

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export function getAllContexts() {
141141
* @param {any} runes
142142
* @param {boolean} [has_async_body]
143143
* @param {Function} [fn]
144-
* @returns {void}
145144
*/
146145
export function push(props, runes = false, has_async_body = false, fn) {
147146
component_context = {
@@ -159,33 +158,40 @@ export function push(props, runes = false, has_async_body = false, fn) {
159158
component_context.function = fn;
160159
dev_current_component_function = fn;
161160
}
161+
162+
return component_context;
162163
}
163164

164165
/**
165166
* @template {Record<string, any>} T
167+
* @param {ComponentContext} context
166168
* @param {T} [component]
167169
* @returns {T}
168170
*/
169-
export function pop(component) {
170-
var context = /** @type {ComponentContext} */ (component_context);
171-
if (context.a) {
171+
export function pop(context, component) {
172+
var ctx = /** @type {ComponentContext} */ (component_context);
173+
if (context !== ctx) {
174+
console.log('h');
175+
return component ?? /** @type {T} */ ({});
176+
}
177+
if (ctx.a) {
172178
return component ?? /** @type {T} */ ({});
173179
}
174-
var effects = context.e;
180+
var effects = ctx.e;
175181
console.log(effects);
176182
if (effects !== null) {
177-
context.e = null;
183+
ctx.e = null;
178184

179185
for (var fn of effects) {
180186
create_user_effect(fn);
181187
}
182188
}
183189

184190
if (component !== undefined) {
185-
context.x = component;
191+
ctx.x = component;
186192
}
187193

188-
component_context = context.p;
194+
component_context = ctx.p;
189195

190196
if (DEV) {
191197
dev_current_component_function = component_context?.function ?? null;

packages/svelte/src/internal/client/reactivity/async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export async function async_body(fn, is_component = false) {
201201
console.log('hi');
202202
ctx.a = false;
203203
running_deferred_effects = true;
204-
pop();
204+
pop(ctx);
205205
running_deferred_effects = false;
206206
}
207207
}

0 commit comments

Comments
 (0)