From 8ece85127a1a802286049e4470527c03a3b3e60d Mon Sep 17 00:00:00 2001 From: Robin Scholtes Date: Fri, 12 May 2023 17:55:41 +1200 Subject: [PATCH] remove unneccesary array length checks --- src/web/waiters/RecipeWaiter.mjs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index 4dfed642..9e4eee3a 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -598,12 +598,9 @@ class RecipeWaiter { clearAllSelectedClasses() { const list = document.querySelectorAll(".operation.selected"); - // check if any operations are selected at all to prevent errors - if (list.length) { - list.forEach((item) => { - item.classList.remove("selected"); - }); - } + list.forEach((item) => { + item.classList.remove("selected"); + }); } /** @@ -642,17 +639,15 @@ class RecipeWaiter { this.clearAllSelectedClasses(); - if (recipeList.length) { - recipeList.forEach((ingredient) => { - const ingredientName = ingredient.getAttribute("data-name"); + recipeList.forEach((ingredient) => { + const ingredientName = ingredient.getAttribute("data-name"); - operations.forEach((operation) => { - if (ingredientName === operation.getAttribute("data-name")) { - this.addSelectedClass(ingredientName); - } - }); + operations.forEach((operation) => { + if (ingredientName === operation.getAttribute("data-name")) { + this.addSelectedClass(ingredientName); + } }); - } + }); } }