Skip to content

Commit 174ddcb

Browse files
committed
pass radix to parseInt function (to avoid unnecessary checks and unwanted side effects)
1 parent 3f71e32 commit 174ddcb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/js/02-on-this-page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
var sidebar = document.querySelector('aside.toc.sidebar')
55
if (!sidebar) return
66
if (document.querySelector('body.-toc')) return sidebar.parentNode.removeChild(sidebar)
7-
var levels = parseInt(sidebar.dataset.levels || 2)
7+
var levels = parseInt(sidebar.dataset.levels || 2, 10)
88
if (levels < 0) return
99

1010
var articleSelector = 'article.doc'
@@ -30,7 +30,7 @@
3030
link.textContent = heading.textContent
3131
links[(link.href = '#' + heading.id)] = link
3232
var listItem = document.createElement('li')
33-
listItem.dataset.level = parseInt(heading.nodeName.slice(1)) - 1
33+
listItem.dataset.level = parseInt(heading.nodeName.slice(1), 10) - 1
3434
listItem.appendChild(link)
3535
accum.appendChild(listItem)
3636
return accum

src/js/05-mobile-navbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if (menu.classList.toggle('is-active')) {
1414
menu.style.maxHeight = ''
1515
var expectedMaxHeight = window.innerHeight - Math.round(menu.getBoundingClientRect().top)
16-
var actualMaxHeight = parseInt(window.getComputedStyle(menu).maxHeight)
16+
var actualMaxHeight = parseInt(window.getComputedStyle(menu).maxHeight, 10)
1717
if (actualMaxHeight !== expectedMaxHeight) menu.style.maxHeight = expectedMaxHeight + 'px'
1818
}
1919
}

0 commit comments

Comments
 (0)