25 lines
587 B
JavaScript
25 lines
587 B
JavaScript
import { deleteTooltip } from "./tooltip.js";
|
|
|
|
export class DomList {
|
|
list;
|
|
template;
|
|
|
|
constructor(rootElem) {
|
|
this.list = rootElem;
|
|
this.template = this.list.querySelector("template").content.firstElementChild;
|
|
}
|
|
|
|
clear() {
|
|
this.list.querySelectorAll("[data-tooltip]").forEach(e => deleteTooltip(Number(e.dataset.tooltip)))
|
|
this.list.replaceChildren(...this.list.querySelectorAll(":scope > template, :scope > [data-keep]"));
|
|
}
|
|
|
|
makeItem() {
|
|
return document.importNode(this.template, true);
|
|
}
|
|
|
|
addItem(item) {
|
|
this.list.appendChild(item);
|
|
}
|
|
}
|