Simplify DomHelper.getVisibleElements

Use a `filter` instead of a loop with an index.
This commit is contained in:
jvoisin 2024-03-11 00:20:55 +01:00 committed by Frédéric Guillot
parent c51a3270da
commit fd1fee852c

View file

@ -22,16 +22,8 @@ class DomHelper {
} }
static getVisibleElements(selector) { static getVisibleElements(selector) {
let elements = document.querySelectorAll(selector); const elements = document.querySelectorAll(selector);
let result = []; return [...elements].filter((element) => this.isVisible(element));
for (let i = 0; i < elements.length; i++) {
if (this.isVisible(elements[i])) {
result.push(elements[i]);
}
}
return result;
} }
static hasPassiveEventListenerOption() { static hasPassiveEventListenerOption() {