|
|
@ -39,15 +39,16 @@ class BoardGameComponent extends HTMLElement { |
|
|
|
for (const [slotName, templateName] of Object.entries(slotTemplateNames)) { |
|
|
|
for (const [slotName, templateName] of Object.entries(slotTemplateNames)) { |
|
|
|
this.querySelectorAll(`.${slotName}`).forEach((slot) => { |
|
|
|
this.querySelectorAll(`.${slotName}`).forEach((slot) => { |
|
|
|
if (slot.getAttribute("data-current-template") !== templateName) { |
|
|
|
if (slot.getAttribute("data-current-template") !== templateName) { |
|
|
|
const template = this.querySelector(`template[name="${templateName}"]`); |
|
|
|
|
|
|
|
if (template) { |
|
|
|
|
|
|
|
while (slot.lastChild) { |
|
|
|
while (slot.lastChild) { |
|
|
|
slot.removeChild(slot.lastChild); |
|
|
|
slot.removeChild(slot.lastChild); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const template = this.querySelector(`template[name="${templateName}"]`); |
|
|
|
|
|
|
|
if (template) { |
|
|
|
slot.appendChild(template.content.cloneNode(true)); |
|
|
|
slot.appendChild(template.content.cloneNode(true)); |
|
|
|
slot.setAttribute("data-current-template", templateName); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
slot.setAttribute("data-current-template", templateName); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|