mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-21 19:08:24 +01:00
Fix: prevent fileInput.js from adding event listeners more than once (#2365)
Fix fileInput.js adding event listeners more than once - Fix a bug that caused fileInput.js to add event listeners more than once per HTML file as it's included in fileSelector fragment in fragments/common.html thus it's being loaded N times where N is the number of file selectors / custom file chooser / file input elements per HTML file, which resulted in each event actions being executed N times as well, which was prevalent in drag and drop operations such as dragging and dropping a file called y.png, it would be duplicated N times (as in /sign path).
This commit is contained in:
parent
db02fba31f
commit
04ccdf6f76
@ -1,6 +1,10 @@
|
|||||||
|
let isScriptExecuted = false;
|
||||||
|
if (!isScriptExecuted) {
|
||||||
|
isScriptExecuted = true;
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
document.querySelectorAll(".custom-file-chooser").forEach(setupFileInput);
|
document.querySelectorAll(".custom-file-chooser").forEach(setupFileInput);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setupFileInput(chooser) {
|
function setupFileInput(chooser) {
|
||||||
const elementId = chooser.getAttribute("data-bs-element-id");
|
const elementId = chooser.getAttribute("data-bs-element-id");
|
||||||
|
Loading…
Reference in New Issue
Block a user