VTable/packages/vtable/__tests__/dom.ts

24 lines
525 B
TypeScript
Raw Normal View History

2023-06-05 10:48:40 +00:00
export function createDiv(container: HTMLElement = document.body): HTMLElement {
const div = document.createElement('div');
container.appendChild(div);
return div;
}
export function createCanvas(container: HTMLElement = document.body, style?: CSSStyleSheet): HTMLCanvasElement {
const canvas = document.createElement('canvas');
container.appendChild(canvas);
return canvas;
}
export function removeDom(dom: HTMLElement) {
const parent = dom.parentNode;
if (parent) {
parent.removeChild(dom);
}
}