[ad_1]
Your codeblock here, has a slight bug
// from
// open closed details elements for printing
window.addEventListener('beforeprint',() =>
{
const allDetails = document.body.querySelectorAll('details');
for(let i=0; i<allDetails.length; i++) { if(allDetails[i].open) { allDetails[i].dataset.open = '1'; } else { allDetails[i].setAttribute('open', ''); } } }); // after printing close details elements not opened before window.addEventListener('afterprint',() =>
{
const allDetails = document.body.querySelectorAll('details');
for(let i=0; i<allDetails.length; i++)
{
if(allDetails[i].dataset.open)
{
allDetails[i].dataset.open = '';
}
else
{
allDetails[i].removeAttribute('open');
}
}
});It should look like
window.addEventListener('beforeprint',() =>
{
const allDetails = document.body.querySelectorAll('details');
for(let i=0; i<allDetails.length; i++) {
if(allDetails[i].open) {
allDetails[i].dataset.open = '1';
} else {
allDetails[i].setAttribute('open', '');
}
}
}); // after printing close details elements not opened before
window.addEventListener('afterprint',() =>
{
const allDetails = document.body.querySelectorAll('details');
for(let i=0; i<allDetails.length; i++)
{
if(allDetails[i].dataset.open)
{
allDetails[i].dataset.open = '';
}
else
{
allDetails[i].removeAttribute('open');
}
}
});In the process of smashing the first window.addEventListener into one line, you inadvertently included the *second* window.addEventListener into the comment preceding it
