chore: more hydration stuff (#10894)

* simplify

* put memory cleanup where it belongs
pull/10895/head
Rich Harris 1 year 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) { export function hydrate_block_anchor(node) {
if (!hydrating) return; if (!hydrating) return;
if (node.nodeType === 8) { // @ts-ignore
// @ts-ignore var nodes = node.$$fragment ?? get_hydrate_nodes(node);
let nodes = node.$$fragment; set_hydrate_nodes(nodes);
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]);
}
} }
/** /**
@ -124,6 +111,10 @@ export function capture_fragment_from_node(node) {
const target = /** @type {Node} */ (last_child.nextSibling); const target = /** @type {Node} */ (last_child.nextSibling);
// @ts-ignore // @ts-ignore
target.$$fragment = nodes; target.$$fragment = nodes;
schedule_task(() => {
// @ts-expect-error clean up memory
target.$$fragment = undefined;
});
return target; return target;
} }
return node; return node;

Loading…
Cancel
Save