From bcd69879107a806c406beae34e4794d8ffc5668a Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Wed, 24 Jul 2024 15:39:57 +0800 Subject: [PATCH] :bug: Fix(ignore): TypeError: Cannot read properties of null (reading 'cloneNode') --- assets/js/theme.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/js/theme.js b/assets/js/theme.js index cb0150d2..fd6fd1d9 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -581,9 +581,11 @@ class FixIt { if (typeof APlayer === 'function') { // remove APlayer click event listener of the toc link let $tocCore = document.getElementById('TableOfContents'); - const $newTocCore = $tocCore.cloneNode(true); - $tocCore.parentElement.replaceChild($newTocCore, $tocCore); - $tocCore = $newTocCore; + if ($tocCore) { + const $newTocCore = $tocCore.cloneNode(true); + $tocCore.parentElement.replaceChild($newTocCore, $tocCore); + $tocCore = $newTocCore; + } // remove APlayer click event listener of the heading mark this.util.forEach(document.querySelectorAll('.heading-mark'), ($headingMark) => { const $newHeadingMark = $headingMark.cloneNode(true);