Skip to content

Commit 473f317

Browse files
davedoesdevtmcw
authored andcommitted
fix: Fix filtering in the default theme
1 parent 15bd7af commit 473f317

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/default_theme/assets/site.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ document.getElementById('filter-input').addEventListener('keyup', function(e) {
3030

3131
if (!value.match(/^\s*$/)) {
3232
match = function(element) {
33-
return element.firstChild.innerHTML.toLowerCase().indexOf(value) !== -1;
33+
var html = element.firstChild.innerHTML;
34+
return html && html.toLowerCase().indexOf(value) !== -1;
3435
};
3536
}
3637

@@ -83,14 +84,16 @@ function toggleSibling() {
8384
}
8485

8586
function showHashTarget(targetId) {
86-
var hashTarget = document.getElementById(targetId);
87-
// new target is hidden
88-
if (
89-
hashTarget &&
90-
hashTarget.offsetHeight === 0 &&
91-
hashTarget.parentNode.parentNode.classList.contains('display-none')
92-
) {
93-
hashTarget.parentNode.parentNode.classList.remove('display-none');
87+
if (targetId) {
88+
var hashTarget = document.getElementById(targetId);
89+
// new target is hidden
90+
if (
91+
hashTarget &&
92+
hashTarget.offsetHeight === 0 &&
93+
hashTarget.parentNode.parentNode.classList.contains('display-none')
94+
) {
95+
hashTarget.parentNode.parentNode.classList.remove('display-none');
96+
}
9497
}
9598
}
9699

0 commit comments

Comments
 (0)