fix: decode anchor hash string to support Chinese characters
authorKonrumi <konrumi@gmail.com>
Sun, 8 Mar 2020 05:07:34 +0000 (05:07 +0000)
committerDan Allen <dan@opendevise.com>
Wed, 18 Mar 2020 22:19:17 +0000 (22:19 +0000)
(cherry picked from commit 810652e445545efbf20a6a3e93ce4365ed534516)

src/js/02-fragment-jumper.js

index 186a193..e3b6ed5 100644 (file)
@@ -31,7 +31,7 @@
 
   Array.prototype.slice.call(document.querySelectorAll('a[href^="#"]')).forEach(function (el) {
     var hash, target
-    if ((hash = el.hash.slice(1)) && (target = document.getElementById(hash))) {
+    if ((hash = decodeURIComponent(el.hash.slice(1))) && (target = document.getElementById(hash))) {
       el.addEventListener('click', jumpToAnchor.bind(target))
     }
   })