1export function portalToBody(node: HTMLElement) {
2 if (typeof document === 'undefined') {
3 return;
4 }
5
6 const target = document.body;
7 if (!target) {
8 return;
9 }
10
11 target.appendChild(node);
12
13 return {
14 destroy() {
15 if (node.parentNode === target) {
16 target.removeChild(node);
17 }
18 }
19 };
20}