Skip to content

Commit f229ad4

Browse files
author
committed
Deployed 7aa6718 with MkDocs version: 1.6.1
1 parent 99923b4 commit f229ad4

3 files changed

Lines changed: 17 additions & 77 deletions

File tree

js/base.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ document.addEventListener("DOMContentLoaded", function () {
5757
var page;
5858
switch (key) {
5959
case shortcuts.next:
60-
page = document.querySelector('.navbar a[rel="next"]:first').getAttribute('href');
60+
page = document.querySelector('.navbar a[rel="next"]');
6161
break;
6262
case shortcuts.previous:
63-
page = document.querySelector('.navbar a[rel="prev"]:first').getAttribute('href');
63+
page = document.querySelector('.navbar a[rel="prev"]');
6464
break;
6565
case shortcuts.search:
6666
e.preventDefault();
@@ -74,9 +74,9 @@ document.addEventListener("DOMContentLoaded", function () {
7474
break;
7575
default: break;
7676
}
77-
if (page) {
77+
if (page && page.hasAttribute('href')) {
7878
keyboard_modal.hide();
79-
window.location.href = page;
79+
window.location.href = page.getAttribute('href');
8080
}
8181
});
8282

@@ -91,7 +91,7 @@ document.addEventListener("DOMContentLoaded", function () {
9191

9292
// First, close any sibling dropdowns.
9393
var container = item.parentElement.parentElement;
94-
container.querySelectorAll('> .dropdown-submenu > a').forEach(function(el) {
94+
container.querySelectorAll(':scope > .dropdown-submenu > a').forEach(function(el) {
9595
if (el !== item) {
9696
hideInnerDropdown(el);
9797
}
@@ -118,8 +118,14 @@ document.addEventListener("DOMContentLoaded", function () {
118118
item.classList.remove('open');
119119

120120
popup.scrollTop = 0;
121-
popup.querySelector('.dropdown-menu').scrollTop = 0;
122-
popup.querySelector('.dropdown-submenu > a').classList.remove('open');
121+
var menu = popup.querySelector('.dropdown-menu');
122+
if (menu) {
123+
menu.scrollTop = 0;
124+
}
125+
var dropdown = popup.querySelector('.dropdown-submenu > a');
126+
if (dropdown) {
127+
dropdown.classList.remove('open');
128+
}
123129
}
124130

125131
document.querySelectorAll('.dropdown-submenu > a').forEach(function(item) {
@@ -138,7 +144,10 @@ document.addEventListener("DOMContentLoaded", function () {
138144
document.querySelectorAll('.dropdown-menu').forEach(function(menu) {
139145
menu.parentElement.addEventListener('hide.bs.dropdown', function() {
140146
menu.scrollTop = 0;
141-
menu.querySelector('.dropdown-submenu > a').classList.remove('open');
147+
var dropdown = menu.querySelector('.dropdown-submenu > a');
148+
if (dropdown) {
149+
dropdown.classList.remove('open');
150+
}
142151
menu.querySelectorAll('.dropdown-menu .dropdown-menu').forEach(function(submenu) {
143152
submenu.classList.remove('show');
144153
});

0 commit comments

Comments
 (0)