From 8649b90a04edff1f3a507094038cf1789287d4c5 Mon Sep 17 00:00:00 2001 From: Robin Scholtes Date: Fri, 12 May 2023 17:58:56 +1200 Subject: [PATCH] optimise addSelectedClass func --- src/web/waiters/RecipeWaiter.mjs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index 9e4eee3a..f25e3ab9 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -611,14 +611,7 @@ class RecipeWaiter { * @param {string} opDataName the data-name of the target operation */ addSelectedClass(opDataName) { - const list = document.querySelectorAll(".operation"); - const item = Array.from(list).filter((item) => item.getAttribute("data-name") === opDataName); - - // when an item is listed in favourites, there are 2 of - // them and both need the 'selected' class ( checkmark ) - item.forEach((op) => { - op.classList.add("selected"); - }); + document.querySelector(`.operation[data-name="${opDataName}"]`).classList.add("selected"); } /**