diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html index 36931f1..9992671 100644 --- a/layouts/partials/head/scripts.html +++ b/layouts/partials/head/scripts.html @@ -268,12 +268,14 @@ tocElem.querySelector('a[href="#' + id + '"]') ? tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null; - tableOfContentsElem.querySelector('ul') ? - tableOfContentsElem.querySelector('ul').querySelectorAll('li').forEach(function (liElem) { + tableOfContentsElem.querySelectorAll('ul') ? + tableOfContentsElem.querySelectorAll('ul').forEach(function (rootUl) { + rootUl.querySelectorAll('li').forEach(function (liElem) { liElem.querySelectorAll('ul').forEach(function (ulElem) { ulElem.style.display = 'none'; }); - }) : null; + }); + }) : null; var curElem = tableOfContentsElem.querySelector("[href='#" + id + "']"); if (curElem && curElem.nextElementSibling) { @@ -332,13 +334,14 @@ tocElem.querySelector('a[href="#' + id + '"]') ? tocElem.querySelector('a[href="#' + id + '"]').classList.add('active') : null; + tableOfContentsElem.querySelectorAll('ul') ? tableOfContentsElem.querySelectorAll('ul').forEach(function (rootUl) { rootUl.querySelectorAll('li').forEach(function (liElem) { liElem.querySelectorAll('ul').forEach(function (ulElem) { ulElem.style.display = 'none'; }); }); - }); + }) : null; var curElem = tableOfContentsElem.querySelector("[href='#" + id + "']"); if (curElem && curElem.nextElementSibling) { diff --git a/layouts/partials/script/single-script.html b/layouts/partials/script/single-script.html index 4a1f157..f115020 100644 --- a/layouts/partials/script/single-script.html +++ b/layouts/partials/script/single-script.html @@ -121,10 +121,12 @@ if ((enableToc || toc) && document.querySelector('.toc')) { var tableOfContentsElem = document.querySelector('.toc').querySelector('#TableOfContents'); - tableOfContentsElem.querySelector('ul') ? - tableOfContentsElem.querySelector('ul').querySelectorAll('li').forEach(function (liElem) { - liElem.querySelectorAll('ul').forEach(function (ulElem) { - ulElem.style.display = 'none'; + tableOfContentsElem.querySelectorAll('ul') ? + tableOfContentsElem.querySelectorAll('ul').forEach(function (rootUl) { + rootUl.querySelectorAll('li').forEach(function (liElem) { + liElem.querySelectorAll('ul').forEach(function (ulElem) { + ulElem.style.display = 'none'; + }); }); }) : null; @@ -142,13 +144,6 @@ }); elem.classList.add('active'); - tableOfContentsElem.querySelector('ul') ? - tableOfContentsElem.querySelector('ul').querySelectorAll('li').forEach(function (liElem) { - liElem.querySelectorAll('ul').forEach(function (ulElem) { - ulElem.style.display = 'none'; - }); - }) : null; - var curElem = tableOfContentsElem.querySelector('[href="#' + id + '"]'); if (curElem && curElem.nextElementSibling) { curElem.nextElementSibling.style.display = 'block';