16 lines
286 B
TypeScript
16 lines
286 B
TypeScript
export default function (node: Element, target = 'body') {
|
|
const targetEl = document.querySelector(target);
|
|
|
|
if (targetEl) {
|
|
targetEl.appendChild(node);
|
|
}
|
|
|
|
return {
|
|
destroy() {
|
|
if (node.parentNode) {
|
|
node.parentNode.removeChild(node);
|
|
}
|
|
}
|
|
};
|
|
}
|