chore: more hydration stuff (#10894)

* simplify

* put memory cleanup where it belongs
pull/10895/head
Rich Harris 7 months ago committed by GitHub
parent 8214075285
commit 89f4e8d53a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -90,22 +90,9 @@ function get_hydrate_nodes(node, insert_text = false) {
export function hydrate_block_anchor(node) {
if (!hydrating) return;
if (node.nodeType === 8) {
// @ts-ignore
let nodes = node.$$fragment;
if (nodes === undefined) {
nodes = get_hydrate_nodes(node);
} else {
schedule_task(() => {
// @ts-expect-error clean up memory
node.$$fragment = undefined;
});
}
set_hydrate_nodes(nodes);
} else {
const first_child = /** @type {Element | null} */ (node.firstChild);
set_hydrate_nodes(first_child === null ? [] : [first_child]);
}
// @ts-ignore
var nodes = node.$$fragment ?? get_hydrate_nodes(node);
set_hydrate_nodes(nodes);
}
/**
@ -124,6 +111,10 @@ export function capture_fragment_from_node(node) {
const target = /** @type {Node} */ (last_child.nextSibling);
// @ts-ignore
target.$$fragment = nodes;
schedule_task(() => {
// @ts-expect-error clean up memory
target.$$fragment = undefined;
});
return target;
}
return node;

Loading…
Cancel
Save