22 lines
418 B
JavaScript
22 lines
418 B
JavaScript
export class DomList {
|
|
list;
|
|
template;
|
|
|
|
constructor(rootElem) {
|
|
this.list = rootElem;
|
|
this.template = this.list.querySelector("template").content.firstElementChild;
|
|
}
|
|
|
|
clear() {
|
|
this.list.replaceChildren(...this.list.querySelectorAll("template, [data-keep]"));
|
|
}
|
|
|
|
makeItem() {
|
|
return document.importNode(this.template, true);
|
|
}
|
|
|
|
addItem(item) {
|
|
this.list.appendChild(item);
|
|
}
|
|
}
|