From fd1fee852cb35fa0f5b0ed6dc0c23b4a6ce368c3 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 11 Mar 2024 00:20:55 +0100 Subject: [PATCH] Simplify DomHelper.getVisibleElements Use a `filter` instead of a loop with an index. --- internal/ui/static/js/dom_helper.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/ui/static/js/dom_helper.js b/internal/ui/static/js/dom_helper.js index fe0afcac..352d6b03 100644 --- a/internal/ui/static/js/dom_helper.js +++ b/internal/ui/static/js/dom_helper.js @@ -22,16 +22,8 @@ class DomHelper { } static getVisibleElements(selector) { - let elements = document.querySelectorAll(selector); - let result = []; - - for (let i = 0; i < elements.length; i++) { - if (this.isVisible(elements[i])) { - result.push(elements[i]); - } - } - - return result; + const elements = document.querySelectorAll(selector); + return [...elements].filter((element) => this.isVisible(element)); } static hasPassiveEventListenerOption() {