Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
web: Avoid slow jQuery :selected selector.
Anders Kaseorg8f2f2654a59d
diff --git a/web/src/billing/upgrade.js b/web/src/billing/upgrade.jsindex ac0bdf81ebb..b01e135554c 100644--- a/web/src/billing/upgrade.js+++ b/web/src/billing/upgrade.js@@ -50,7 +50,7 @@ export const initialize = () => {});$("select[name=organization-type]").on("change", (e) => {- const string_value = $(e.currentTarget).find(":selected").attr("data-string-value");+ const string_value = $(e.currentTarget.selectedOptions).attr("data-string-value");helpers.update_discount_details(string_value);});diff --git a/web/src/portico/integrations_dev_panel.js b/web/src/portico/integrations_dev_panel.jsindex d67d5bd45c2..4e9684e0fde 100644--- a/web/src/portico/integrations_dev_panel.js+++ b/web/src/portico/integrations_dev_panel.js@@ -61,11 +61,11 @@ function set_results_notice(msg, level) {}function get_api_key_from_selected_bot() {- return $("#bot_name").children("option:selected").val();+ return $("#bot_name").val();}function get_selected_integration_name() {- return $("#integration_name").children("option:selected").val();+ return $("#integration_name").val();}function get_fixture_format(fixture_name) {@@ -338,7 +338,7 @@ $(() => {$("#integration_name").on("change", function () {clear_elements(["custom_http_headers", "fixture_body", "fixture_name", "results_notice"]);- const integration_name = $(this).children("option:selected").val();+ const integration_name = $(this.selectedOptions).val();get_fixtures(integration_name);update_url();return;@@ -346,7 +346,7 @@ $(() => {$("#fixture_name").on("change", function () {clear_elements(["fixture_body", "results_notice"]);- const fixture_name = $(this).children("option:selected").val();+ const fixture_name = $(this.selectedOptions).val();load_fixture_body(fixture_name);return;});diff --git a/web/src/portico/signup.js b/web/src/portico/signup.jsindex be0cb4a3f8c..4ad96de57cd 100644--- a/web/src/portico/signup.js+++ b/web/src/portico/signup.js@@ -198,14 +198,15 @@ $(() => {}function update_full_name_section() {- if (- $("#source_realm_select").length &&- $("#source_realm_select").find(":selected").val() !== ""- ) {+ if ($("#source_realm_select").length && $("#source_realm_select").val() !== "") {$("#full_name_input_section").hide();$("#profile_info_section").show();- const avatar_url = $("#source_realm_select").find(":selected").attr("data-avatar");- const full_name = $("#source_realm_select").find(":selected").attr("data-full-name");+ const avatar_url = $($("#source_realm_select").prop("selectedOptions")).attr(+ "data-avatar",+ );+ const full_name = $($("#source_realm_select").prop("selectedOptions")).attr(+ "data-full-name",+ );$("#profile_full_name").text(full_name);$("#id_full_name").val(full_name);$("#profile_avatar").attr("src", avatar_url);diff --git a/web/src/settings_bots.js b/web/src/settings_bots.jsindex f0a3f71fefb..62da87d515e 100644--- a/web/src/settings_bots.js+++ b/web/src/settings_bots.js@@ -206,12 +206,12 @@ export function add_a_new_bot() {let create_avatar_widget;function create_a_new_bot() {- const bot_type = $("#create_bot_type :selected").val();+ const bot_type = $("#create_bot_type").val();const full_name = $("#create_bot_name").val();const short_name = $("#create_bot_short_name").val() || $("#create_bot_short_name").text();const payload_url = $("#create_payload_url").val();const interface_type = $("#create_interface_type").val();- const service_name = $("#select_service_name :selected").val();+ const service_name = $("#select_service_name").val();const formData = new FormData();formData.append("csrfmiddlewaretoken", csrf_token);@@ -267,7 +267,7 @@ export function add_a_new_bot() {create_avatar_widget = avatar.build_bot_create_widget();$("#create_bot_type").on("change", () => {- const bot_type = $("#create_bot_type :selected").val();+ const bot_type = $("#create_bot_type").val();// For "generic bot" or "incoming webhook" both these fields need not be displayed.$("#service_name_list").hide();$("#select_service_name").removeClass("required");@@ -288,7 +288,7 @@ export function add_a_new_bot() {$("#select_service_name").on("change", () => {$("#config_inputbox").children().hide();- const selected_bot = $("#select_service_name :selected").val();+ const selected_bot = $("#select_service_name").val();$(`[name*='${CSS.escape(selected_bot)}']`).show();});}@@ -382,7 +382,7 @@ export function show_edit_bot_info_modal(user_id, from_user_info_popover) {if (bot_type === OUTGOING_WEBHOOK_BOT_TYPE) {const service_payload_url = $("#edit_service_base_url").val();- const service_interface = $("#edit_service_interface :selected").val();+ const service_interface = $("#edit_service_interface").val();formData.append("service_payload_url", JSON.stringify(service_payload_url));formData.append("service_interface", service_interface);} else if (bot_type === EMBEDDED_BOT_TYPE && service !== undefined) {