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.

js: Use jQuery .first() when appropriate.

Anders Kaseorg864abac94636
diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js
index 2a1e317e066..e4c379a9678 100644
--- a/static/js/copy_and_paste.js
+++ b/static/js/copy_and_paste.js
@@ -85,10 +85,9 @@ function construct_copy_div($div, start_id, end_id) {
should_include_start_recipient_header = true;
}
const message = message_lists.current.get(rows.id($row));
- const $message_firstp = $(message.content).slice(0, 1);
- $message_firstp.prepend(message.sender_full_name + ": ");
- $div.append($message_firstp);
- $div.append($(message.content).slice(1));
+ const $content = $(message.content);
+ $content.first().prepend(message.sender_full_name + ": ");
+ $div.append($content);
}
if (should_include_start_recipient_header) {
@@ -218,7 +217,7 @@ export function analyze_selection(selection) {
$startc = $(range.startContainer);
start_data = find_boundary_tr(
- $($startc.parents(".selectable_row, .message_header")[0]),
+ $startc.parents(".selectable_row, .message_header").first(),
($row) => $row.next(),
);
if (start_data === undefined) {
@@ -279,19 +278,19 @@ function get_end_tr_from_endc($endc) {
// If the selection ends within the message following the selected
// messages, go back to use the actual last message.
if ($endc.parents(".message_row").length > 0) {
- const $parent_msg = $($endc.parents(".message_row")[0]);
+ const $parent_msg = $endc.parents(".message_row").first();
return $parent_msg.prev(".message_row");
}
// If it's not in a .message_row, it's probably in a .message_header and
// we can use the last message from the previous recipient_row.
if ($endc.parents(".message_header").length > 0) {
- const $overflow_recipient_row = $($endc.parents(".recipient_row")[0]);
+ const $overflow_recipient_row = $endc.parents(".recipient_row").first();
return $overflow_recipient_row.prev(".recipient_row").last(".message_row");
}
// If somehow we get here, do the default return.
}
- return $($endc.parents(".selectable_row")[0]);
+ return $endc.parents(".selectable_row").first();
}
export function paste_handler_converter(paste_html) {
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index 67ab896038e..69123cb0866 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -146,7 +146,7 @@ export function open_edit_panel_for_row(stream_row) {
}
export function open_edit_panel_empty() {
- const tab_key = $(stream_settings_ui.get_active_data().$tabs[0]).attr("data-tab-key");
+ const tab_key = stream_settings_ui.get_active_data().$tabs.first().attr("data-tab-key");
$(".stream-row.active").removeClass("active");
stream_settings_ui.show_subs_pane.nothing_selected();
setup_subscriptions_tab_hash(tab_key);
diff --git a/static/js/stream_settings_ui.js b/static/js/stream_settings_ui.js
index e8628613ced..1afb688f044 100644
--- a/static/js/stream_settings_ui.js
+++ b/static/js/stream_settings_ui.js
@@ -825,7 +825,7 @@ export function keyboard_sub() {
export function toggle_view(event) {
const active_data = get_active_data();
- const stream_filter_tab = $(active_data.$tabs[0]).text();
+ const stream_filter_tab = active_data.$tabs.first().text();
if (event === "right_arrow" && stream_filter_tab === "Subscribed") {
toggler.goto("all-streams");