File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,25 @@ class MDBookSidebarScrollbox extends HTMLElement {
2222 if (href && !href.startsWith("#") && !/^(?:[a-z+]+:)?\/\//.test(href)) {
2323 link.href = path_to_root + href;
2424 }
25+
26+ var parent = link.parentElement;
27+ if (parent && parent.classList.contains("chapter-item")) {
28+ parent.classList.toggle("expanded");
29+ }
30+
2531 // The "index" page is supposed to alias the first chapter in the book.
2632 if (link.href === current_page || (i === 0 && path_to_root === "" && current_page.endsWith("/index.html"))) {
2733 link.classList.add("active");
28-
29- var parent = link.parentElement;
30- if (parent && parent.classList.contains("chapter-item")) {
31- parent.classList.add("expanded");
32- }
34+
3335 while (parent) {
3436 if (parent.tagName === "LI" && parent.previousElementSibling) {
3537 if (parent.previousElementSibling.classList.contains("chapter-item")) {
36- parent.previousElementSibling.classList.add ("expanded");
38+ parent.previousElementSibling.classList.toggle ("expanded");
3739 }
3840 }
3941 parent = parent.parentElement;
4042 }
43+ /**/
4144 }
4245 }
4346 // Track and set sidebar scroll position
You can’t perform that action at this time.
0 commit comments