use <template> element for cws

This commit is contained in:
Rhiannon Morris 2020-09-14 02:34:21 +02:00
parent 258b1c6102
commit b3da952558
2 changed files with 12 additions and 8 deletions

View file

@ -28,13 +28,10 @@ function setImage(id, src, width, height, href, cw, firstLoad) {
let newCaption;
if (!opened.has(id) && cw) {
let template = document.createElement('template');
template.innerHTML = `
<figcaption id=cw aria-role=button tabindex=0>
<span id=cw-text>cw: <b>${cw}</b></span>
</figcaption>`;
newCaption = template.content;
addCWListeners(id, newCaption.getElementById('cw'));
newCaption = document.getElementById('cw-template')
.content.firstElementChild.cloneNode(true);
newCaption.querySelector('#cw-text').innerHTML = cw;
addCWListeners(id, newCaption.querySelector('#cw'));
}
if (caption) {