consolidate on this page code
authorDan Allen <dan@opendevise.com>
Wed, 8 Apr 2020 08:12:52 +0000 (02:12 -0600)
committerDan Allen <dan@opendevise.com>
Wed, 8 Apr 2020 08:12:52 +0000 (02:12 -0600)
src/js/02-on-this-page.js

index 0403a26..524ef25 100644 (file)
   }, 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) {