fragmentless-branches
Rich Harris 3 months ago
parent 3a40955658
commit d3f6141880

@ -27,6 +27,8 @@ export function hmr(fn) {
let ran = false;
var parent_effect = /** @type {Effect} */ (active_effect);
block(() => {
if (component === (component = get(current))) {
return;
@ -57,7 +59,7 @@ export function hmr(fn) {
// Forward the nodes from the inner effect to the outer active effect which would
// get them if the HMR wrapper wasn't there. Do this inside the block not outside
// so that HMR updates to the component will also update the nodes on the active effect.
/** @type {Effect} */ (active_effect).nodes = effect.nodes;
parent_effect.nodes ??= effect.nodes;
}, EFFECT_TRANSPARENT);
ran = true;

@ -159,9 +159,13 @@ export class BranchManager {
if (fn && !this.#onscreen.has(key) && !this.#offscreen.has(key)) {
if (defer) {
var fragment = document.createDocumentFragment();
var anchor = create_text();
fragment.append(anchor);
this.#offscreen.set(
key,
branch(() => fn(create_text()))
branch(() => fn(anchor))
);
} else {
this.#onscreen.set(

Loading…
Cancel
Save