From 826e4d654f511ea8d1d385bdc09cbed69ff6a70f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 11 Mar 2024 00:28:31 +0100 Subject: [PATCH] Replace DomHelper.findParent with .closest See https://developer.mozilla.org/en-US/docs/Web/API/Element/closest --- internal/ui/static/js/app.js | 2 +- internal/ui/static/js/dom_helper.js | 10 ---------- internal/ui/static/js/touch_handler.js | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/internal/ui/static/js/app.js b/internal/ui/static/js/app.js index 599119a2..9764d3f6 100644 --- a/internal/ui/static/js/app.js +++ b/internal/ui/static/js/app.js @@ -571,7 +571,7 @@ function isListView() { function findEntry(element) { if (isListView()) { if (element) { - return DomHelper.findParent(element, "item"); + return element.closest(".item") } else { return document.querySelector(".current-item"); } diff --git a/internal/ui/static/js/dom_helper.js b/internal/ui/static/js/dom_helper.js index fffa6965..fe0afcac 100644 --- a/internal/ui/static/js/dom_helper.js +++ b/internal/ui/static/js/dom_helper.js @@ -34,16 +34,6 @@ class DomHelper { return result; } - static findParent(element, selector) { - for (; element && element !== document; element = element.parentNode) { - if (element.classList.contains(selector)) { - return element; - } - } - - return null; - } - static hasPassiveEventListenerOption() { var passiveSupported = false; diff --git a/internal/ui/static/js/touch_handler.js b/internal/ui/static/js/touch_handler.js index 99c1d5b2..4e2657cb 100644 --- a/internal/ui/static/js/touch_handler.js +++ b/internal/ui/static/js/touch_handler.js @@ -31,7 +31,7 @@ class TouchHandler { return element; } - return DomHelper.findParent(element, "entry-swipe"); + return element.closest(".entry-swipe") } onItemTouchStart(event) {