put memory cleanup where it belongs

pull/10894/head
Rich Harris 2 years ago
parent 60d1b77dea
commit abb05d2431

@ -90,18 +90,8 @@ 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 hydrating, `node` is a `Comment`
// @ts-ignore // @ts-ignore
let nodes = node.$$fragment; var nodes = node.$$fragment ?? get_hydrate_nodes(node);
if (nodes === undefined) {
nodes = get_hydrate_nodes(node);
} else {
schedule_task(() => {
// @ts-expect-error clean up memory
node.$$fragment = undefined;
});
}
set_hydrate_nodes(nodes); set_hydrate_nodes(nodes);
} }
@ -121,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