toc folding bug fix

This commit is contained in:
zzossig 2020-01-26 21:05:58 +09:00
parent 56e16a54b1
commit 8ccb48fd93
2 changed files with 13 additions and 15 deletions

View File

@ -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) {

View File

@ -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';