From 2e9f1c5cb2ad0c74ddeeecf0afa533139464b54d Mon Sep 17 00:00:00 2001 From: amzrk2 Date: Wed, 3 Jun 2020 18:56:00 +0800 Subject: Fix null pointer error --- assets/js/fuji.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'assets/js') diff --git a/assets/js/fuji.js b/assets/js/fuji.js index 4fbd651..66892af 100644 --- a/assets/js/fuji.js +++ b/assets/js/fuji.js @@ -51,13 +51,18 @@ function updateUtterancesTheme(utterancesFrame) { } } -// load comment -document.querySelector('span.post-comment-notloaded').addEventListener('click', loadComment); +// load comment button only when comment area exist +if (document.querySelector('span.post-comment-notloaded')) { + document.querySelector('span.post-comment-notloaded').addEventListener('click', loadComment); +} // remove empty ul in toc if article only have ## and ### -if (document.querySelectorAll('.sidebar-toc ul ul').length > 0) { - document.querySelectorAll('.sidebar-toc ul ul').forEach((value, key, parent) => { - value.setAttribute('style', 'display: none;'); +var secondQueryOfToc = document.querySelectorAll('.sidebar-toc ul ul'); +if (secondQueryOfToc.length > 0) { + secondQueryOfToc.forEach((value, key, parent) => { + if (value.innerText === '') { + value.setAttribute('style', 'display: none;'); + } }); } -- cgit v1.2.3