🐛 Fix: APlayer invades the click event of the anchor links, resulting in invalid Chinese anchor links scrolling (#292)

This commit is contained in:
Cell
2023-03-03 15:06:30 +08:00
parent 4e20b85420
commit 0b5e40e2bf
4 changed files with 10 additions and 3 deletions
+7 -1
View File
@@ -612,10 +612,16 @@ class FixIt {
* init table of contents
*/
initToc() {
const $tocCore = document.getElementById('TableOfContents');
let $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) {
return;
}
// It's a dirty hack to fix the bug of APlayer, see https://github.com/hugo-fixit/FixIt/issues/292
if (typeof APlayer === 'function') {
const $newTocCore = $tocCore.cloneNode(true);
$tocCore.parentElement.replaceChild($newTocCore, $tocCore);
$tocCore = $newTocCore;
}
if (document.getElementById('toc-static').dataset.kept === true || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {