Skip to content

Commit

Permalink
Simplify DomHelper.getVisibleElements
Browse files Browse the repository at this point in the history
Use a `filter` instead of a loop with an index.
  • Loading branch information
jvoisin authored and fguillot committed Mar 11, 2024
1 parent c51a327 commit fd1fee8
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions internal/ui/static/js/dom_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit fd1fee8

Please sign in to comment.