WebUI: prevent passing wrong parameter

The `event` object will be passed as the first parameter to the event handler. So wrap the
event handler with a closure to prevent `event` leaking to other functions.
This commit is contained in:
Chocobo1 2024-08-09 15:52:46 +08:00
parent e069fbc37f
commit 1179fc3de3
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
4 changed files with 18 additions and 15 deletions

View file

@ -753,14 +753,15 @@ window.qBittorrent.Search ??= (() => {
};
const setupSearchTableEvents = function(enable) {
const clickHandler = (e) => { downloadSearchTorrent(); };
if (enable) {
$$(".searchTableRow").each((target) => {
target.addEventListener("dblclick", downloadSearchTorrent, false);
target.addEventListener("dblclick", clickHandler);
});
}
else {
$$(".searchTableRow").each((target) => {
target.removeEventListener("dblclick", downloadSearchTorrent, false);
target.removeEventListener("dblclick", clickHandler);
});
}
};