TdAI / llama.cpp /tools /ui /src /lib /utils /portal-to-body.ts
tda45's picture
Upload folder using huggingface_hub (part 8)
15c3607 verified
Raw
History Blame Contribute Delete
299 Bytes
export function portalToBody(node: HTMLElement) {
if (typeof document === 'undefined') {
return;
}
const target = document.body;
if (!target) {
return;
}
target.appendChild(node);
return {
destroy() {
if (node.parentNode === target) {
target.removeChild(node);
}
}
};
}