diff --git a/modules/helfi_toc/assets/js/tableOfContents.js b/modules/helfi_toc/assets/js/tableOfContents.js index 5ace846b2..5e3e03070 100644 --- a/modules/helfi_toc/assets/js/tableOfContents.js +++ b/modules/helfi_toc/assets/js/tableOfContents.js @@ -183,12 +183,15 @@ content.setAttribute('id', anchorName); }); - // Remove loading text. if (tableOfContents) { - const removeElements = tableOfContents.querySelectorAll('.js-remove'); + // Remove loading text and noscript element. + const removeElements = tableOfContents.parentElement.querySelectorAll('.js-remove'); removeElements.forEach(function (element) { element.remove(); }); + + // Update toc visible. + tableOfContents.setAttribute('data-js', 'true'); } }, };