From 13b85c7c54e5659caf359ec536708bb80e032e86 Mon Sep 17 00:00:00 2001 From: Blake Gearin Date: Sun, 3 Apr 2022 20:22:10 -0500 Subject: Fix forEach error on empty variable --- assets/js/index.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/assets/js/index.js b/assets/js/index.js index 67496d4..28411e4 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -109,7 +109,7 @@ function loadActions() { tocItems.forEach(function(item){ pushClass(item, 'toc_item'); pushClass(item.firstElementChild, 'toc_link'); - }) + }); } }); @@ -143,12 +143,14 @@ function loadActions() { } const paragraphs = elems('p'); - paragraphs.forEach(function(p){ - const buttons = elems('.button', p); - if(buttons.length > 1) { - pushClass(p, 'button_grid'); - } - }); + if (paragraphs) { + paragraphs.forEach(function(p){ + const buttons = elems('.button', p); + if(buttons.length > 1) { + pushClass(p, 'button_grid'); + } + }); + } })(); (function markExternalLinks(){ @@ -216,7 +218,7 @@ function loadActions() { copyText.innerText = 'Link Copied'; if(!elem(`.${yanked}`, parent)) { parent.appendChild(copyText); - setTimeout(function() { + setTimeout(function() { parent.removeChild(copyText) }, 2250); } @@ -378,7 +380,7 @@ function loadActions() { } else { deleteClass(toTop, active); } - }) + }); })(); } -- cgit v1.2.3