Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

upload: Don’t leak an extra body event handler for each edited message.

Anders Kaseorg9b6301c75522
diff --git a/web/src/upload.js b/web/src/upload.js
index 203a6d5ae79..934702f1bae 100644
--- a/web/src/upload.js
+++ b/web/src/upload.js
@@ -284,7 +284,7 @@ export function setup_upload(config) {
});
});
- $("body").on("change", get_item("file_input_identifier", config), (event) => {
+ $(get_item("file_input_identifier", config)).on("change", (event) => {
const files = event.target.files;
upload_files(uppy, config, files);
get_item("textarea", config).trigger("focus");
diff --git a/web/tests/upload.test.js b/web/tests/upload.test.js
index c1d62831d1b..652da9b4930 100644
--- a/web/tests/upload.test.js
+++ b/web/tests/upload.test.js
@@ -388,7 +388,7 @@ test("uppy_config", () => {
test("file_input", ({override_rewire}) => {
upload.setup_upload({mode: "compose"});
- const change_handler = $("body").get_on_handler("change", "#compose .file_input");
+ const change_handler = $("#compose .file_input").get_on_handler("change");
const files = ["file1", "file2"];
const event = {
target: {