use <template> element for cws
This commit is contained in:
parent
258b1c6102
commit
b3da952558
2 changed files with 12 additions and 8 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue