Closed Skateside closed 1 year ago
class Template { // ... draw(populates) { const clone = this.template.content.cloneNode(true); Object.entries(populates).forEach(([selector, populate]) => { lookup(selector, clone).forEach((element) => populate(element)); }); return clone; } }
This allows a simpler interface and gets rid of the default population interfaces
template.draw({ ".js--character--leaves"(element) { element.classList.toggle("character--setup", setup); element.classList.toggle("character--left-1", firstNight); element.classList.toggle("character--right-1", otherNight); const top = reminders.length + remindersGlobal.length; element.classList.toggle(`character--top-${top}`, top); }, ".js--character--image"(element) { element.src = image; }, ".js--character--name"(element) { element.textContent = name; } });
Might reduce the code a little, speeding things up a tad
This allows a simpler interface and gets rid of the default population interfaces
Might reduce the code a little, speeding things up a tad