From 31255b8f699150824a8256ae31e4dda09891ff3d Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 8 Apr 2020 02:12:52 -0600 Subject: [PATCH] consolidate on this page code --- src/js/02-on-this-page.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/js/02-on-this-page.js b/src/js/02-on-this-page.js index 0403a26..524ef25 100644 --- a/src/js/02-on-this-page.js +++ b/src/js/02-on-this-page.js @@ -30,10 +30,7 @@ }, document.createElement('ul')) var menu = sidebar.querySelector('.toc-menu') - if (!menu) { - menu = document.createElement('div') - menu.className = 'toc-menu' - } + if (!menu) (menu = document.createElement('div')).className = 'toc-menu' var title = document.createElement('h3') title.textContent = sidebar.dataset.title || 'Contents' @@ -69,9 +66,7 @@ } if (activeFragment) { if (activeFragment !== lastActiveFragment) { - if (lastActiveFragment) { - links[lastActiveFragment].classList.remove('is-active') - } + if (lastActiveFragment) links[lastActiveFragment].classList.remove('is-active') var activeLink = links[activeFragment] activeLink.classList.add('is-active') if (list.scrollHeight > list.offsetHeight) { -- 2.11.0