Skip to content

Commit

Permalink
Fix invalid selector
Browse files Browse the repository at this point in the history
* See: #19
  • Loading branch information
stevenjoezhang committed Jun 2, 2020
1 parent 5f6271d commit b0d92b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ NexT.utils = {
[...target.parentNode.children].forEach(element => {
element.classList.toggle('active', element === target);
});
const tActive = document.querySelector(target.querySelector('a').getAttribute('href'));
// https://stackoverflow.com/questions/20306204/using-queryselector-with-ids-that-are-numbers
const tActive = document.getElementById(target.querySelector('a').getAttribute('href').replace('#', ''));
[...tActive.parentNode.children].forEach(element => {
element.classList.toggle('active', element === tActive);
});
Expand Down Expand Up @@ -235,7 +236,7 @@ NexT.utils = {
const navItems = document.querySelectorAll('.post-toc li');
const sections = [...navItems].map(element => {
const link = element.querySelector('a.nav-link');
const target = document.querySelector(decodeURI(link.getAttribute('href')));
const target = document.getElementById(decodeURI(link.getAttribute('href')).replace('#', ''));
// TOC item animation navigate.
link.addEventListener('click', event => {
event.preventDefault();
Expand Down

0 comments on commit b0d92b7

Please sign in to comment.