mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
js: Avoid href="#" for buttons with a JavaScript click handler.
As seen in https://chat.zulip.org/#narrow/stream/9-issues/topic/edit.20history.20bug/near/1320430, clicking such a link takes you to the user's default view if the click handler throws an exception before doing preventDefault(). There hrefs also have the negative effect of having your browser claim that clicking the link will navigate you to the default view, which it won't. Comes with a linter rule to prevent future instances, since it seems there are some recently added ones, though they are likely the result of copy/paste.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<ul class="nav nav-list actions_popover">
|
||||
{{#if should_display_hide_option}}
|
||||
<li>
|
||||
<a href="#" class="rehide_muted_user_message" data-message-id="{{message_id}}">
|
||||
<a class="rehide_muted_user_message" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-eye-slash" aria-hidden="true"></i>
|
||||
{{t "Hide muted message again" }}
|
||||
</a>
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
{{#if should_display_edit_and_view_source}}
|
||||
<li>
|
||||
<a href="#" class="popover_edit_message" data-message-id="{{message_id}}">
|
||||
<a class="popover_edit_message" data-message-id="{{message_id}}">
|
||||
<i class="{{#if use_edit_icon}}fa fa-pencil{{else}}fa fa-file-code-o{{/if}}" aria-hidden="true"></i> {{editability_menu_item}}
|
||||
<span class="hotkey-hint">(e)</span>
|
||||
</a>
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
{{#if should_display_quote_and_reply}}
|
||||
<li>
|
||||
<a href="#" class="respond_button" data-message-id="{{message_id}}">
|
||||
<a class="respond_button" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-reply" aria-hidden="true"></i> {{t "Quote and reply or forward" }}
|
||||
<span class="hotkey-hint">(>)</span>
|
||||
</a>
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
{{#if should_display_reminder_option}}
|
||||
<li>
|
||||
<a href="#" class='reminder_button' data-message-id="{{message_id}}">
|
||||
<a class='reminder_button' data-message-id="{{message_id}}">
|
||||
<i class="fa fa-bell" aria-hidden="true"></i> {{t "Remind me about this" }}
|
||||
</a>
|
||||
</li>
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
{{#if should_display_collapse}}
|
||||
<li>
|
||||
<a href="#" class="popover_toggle_collapse" data-message-id="{{message_id}}">
|
||||
<a class="popover_toggle_collapse" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-minus" aria-hidden="true"></i>
|
||||
{{t "Collapse" }} <span class="hotkey-hint">(–)</span>
|
||||
</a>
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
{{#if should_display_uncollapse}}
|
||||
<li>
|
||||
<a href="#" class="popover_toggle_collapse" data-message-id="{{message_id}}">
|
||||
<a class="popover_toggle_collapse" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||
{{t "Un-collapse" }} <span class="hotkey-hint">(–)</span>
|
||||
</a>
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
{{#if should_display_edit_history_option}}
|
||||
<li>
|
||||
<a href="#" class="view_edit_history" data-message-id="{{message_id}}">
|
||||
<a class="view_edit_history" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-clock-o" aria-hidden="true"></i>
|
||||
{{t "View edit history" }}
|
||||
</a>
|
||||
@@ -63,7 +63,7 @@
|
||||
{{/if}}
|
||||
{{#if should_display_delete_option}}
|
||||
<li>
|
||||
<a href="#" class="delete_message" data-message-id="{{message_id}}">
|
||||
<a class="delete_message" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-times" aria-hidden="true"></i>
|
||||
{{t "Delete message" }}
|
||||
</a>
|
||||
@@ -71,7 +71,7 @@
|
||||
{{/if}}
|
||||
{{#if can_mute_topic}}
|
||||
<li>
|
||||
<a href="#" class="popover_mute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
|
||||
<a class="popover_mute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
|
||||
<i class="fa fa-bell-slash" aria-hidden="true"></i>
|
||||
{{#tr}}Mute the topic <b>{topic}</b>{{/tr}} <span class="hotkey-hint">(M)</span>
|
||||
</a>
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
{{#if can_unmute_topic}}
|
||||
<li>
|
||||
<a href="#" class="popover_unmute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
|
||||
<a class="popover_unmute_topic" data-msg-stream-id="{{stream_id}}" data-msg-topic="{{topic}}">
|
||||
<i class="fa fa-bell" aria-hidden="true"></i>
|
||||
{{#tr}}Unmute the topic <b>{topic}</b>{{/tr}}
|
||||
</a>
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
{{#if should_display_add_reaction_option}}
|
||||
<li>
|
||||
<a href="#" class="reaction_button" data-message-id="{{message_id}}">
|
||||
<a class="reaction_button" data-message-id="{{message_id}}">
|
||||
<i class="fa fa-smile-o" aria-hidden="true"></i>
|
||||
{{#tr}}Add emoji reaction{{/tr}}
|
||||
</a>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ul class="nav" role="navigation">
|
||||
<li class="dropdown actual-dropdown-menu" id="gear-menu">
|
||||
<a id="settings-dropdown" href="#" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{t 'Menu' }} (g)">
|
||||
<a id="settings-dropdown" role="button" class="dropdown-toggle" data-target="nada" data-toggle="dropdown" title="{{t 'Menu' }} (g)">
|
||||
<i class="fa fa-cog settings-dropdown-cog" aria-hidden="true"></i>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="settings-dropdown">
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="topics_header">
|
||||
<a href="" class="show-all-streams"> <i class="fa fa-chevron-left" aria-hidden="true"></i>{{t 'Back to streams' }}</a>
|
||||
<a class="show-all-streams"> <i class="fa fa-chevron-left" aria-hidden="true"></i>{{t 'Back to streams' }}</a>
|
||||
</div>
|
||||
<div id="stream-filters-container" class="scrolling_list" data-simplebar>
|
||||
<ul id="stream_filters" class="filters"></ul>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<li class="topic-list-item show-more-topics bottom_left_row {{#unless more_topics_unreads}}zero-topic-unreads{{/unless}}">
|
||||
<span class='topic-box'>
|
||||
<a class="topic-name" href="#">{{t "more topics" }}</a>
|
||||
<a class="topic-name">{{t "more topics" }}</a>
|
||||
<span class="unread_count {{#unless more_topics_unreads}}zero_count{{/unless}}">
|
||||
{{more_topics_unreads}}
|
||||
</span>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="column-middle" id="navbar-middle">
|
||||
<div class="column-middle-inner">
|
||||
<div id="streamlist-toggle" {{#if embedded}}class="hide-streamlist-toggle-visibility"{{/if}} title="{{t 'Stream list' }} (q)">
|
||||
<a href="#" id="streamlist-toggle-button" role="button"><i class="fa fa-reorder" aria-hidden="true"></i>
|
||||
<a id="streamlist-toggle-button" role="button"><i class="fa fa-reorder" aria-hidden="true"></i>
|
||||
<span id="streamlist-toggle-unreadcount">0</span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -46,7 +46,7 @@
|
||||
</div>
|
||||
<div class="column-right">
|
||||
<div id="userlist-toggle" title="{{t 'User list' }} (w)">
|
||||
<a href="#" id="userlist-toggle-button" role="button"><i class="fa fa-group" aria-hidden="true"></i>
|
||||
<a id="userlist-toggle-button" role="button"><i class="fa fa-group" aria-hidden="true"></i>
|
||||
<span id="userlist-toggle-unreadcount">0</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
{{! Contents of the "remind me about this actions" popup }}
|
||||
<ul class="nav nav-list remind_me_popover">
|
||||
<li>
|
||||
<a href="#" class="remind in_20m" data-message-id="{{message.id}}">
|
||||
<a class="remind in_20m" data-message-id="{{message.id}}">
|
||||
{{t "in 20 minutes" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" class="remind in_1h" data-message-id="{{message.id}}">
|
||||
<a class="remind in_1h" data-message-id="{{message.id}}">
|
||||
{{t "in 1 hour" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" class="remind in_3h" data-message-id="{{message.id}}">
|
||||
<a class="remind in_3h" data-message-id="{{message.id}}">
|
||||
{{t "in 3 hours" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" class="remind tomo" data-message-id="{{message.id}}">
|
||||
<a class="remind tomo" data-message-id="{{message.id}}">
|
||||
{{t "Tomorrow" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" class="remind nxtw" data-message-id="{{message.id}}">
|
||||
<a class="remind nxtw" data-message-id="{{message.id}}">
|
||||
{{t "Next week" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#" class='remind custom' data-message-id="{{message.id}}">
|
||||
<a class='remind custom' data-message-id="{{message.id}}">
|
||||
{{t "Select date and time" }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{#if is_admin}}
|
||||
<td>
|
||||
<span class="referred_by">
|
||||
<a data-user-id="{{invited_by_user_id}}" href="#" class="view_user_profile">{{referrer_name}}</a>
|
||||
<a data-user-id="{{invited_by_user_id}}" class="view_user_profile">{{referrer_name}}</a>
|
||||
</span>
|
||||
</td>
|
||||
{{/if}}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{{#if no_owner }}
|
||||
{{bot_owner_full_name}}
|
||||
{{else}}
|
||||
<a data-user-id="{{bot_owner_id}}" href="#" class="view_user_profile">{{bot_owner_full_name}}</a>
|
||||
<a data-user-id="{{bot_owner_id}}" class="view_user_profile">{{bot_owner_full_name}}</a>
|
||||
{{/if}}
|
||||
</span>
|
||||
</td>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
|
||||
<div>
|
||||
<a href="#" draggable="false" class="subs_set_all_users">{{t "Check all" }}</a> |
|
||||
<a href="#" draggable="false" class="subs_unset_all_users">{{t "Uncheck all" }}</a>
|
||||
<a draggable="false" class="subs_set_all_users">{{t "Check all" }}</a> |
|
||||
<a draggable="false" class="subs_unset_all_users">{{t "Uncheck all" }}</a>
|
||||
</div>
|
||||
|
||||
<div id="user-checkboxes-simplebar-wrapper" data-simplebar>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
{{#if has_starred_messages}}
|
||||
<li class="hidden-for-spectators">
|
||||
<a href="#" class="sidebar-popover-unstar-all-in-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||
<a class="sidebar-popover-unstar-all-in-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||
<i class="fa fa-star-o" aria-hidden="true"></i>
|
||||
{{#tr}}Unstar all messages in topic{{/tr}}
|
||||
</a>
|
||||
|
||||
@@ -766,6 +766,11 @@ handlebars_rules = RuleList(
|
||||
"pattern": r'"{{t "',
|
||||
"description": "Invalid quoting for HTML element with translated string.",
|
||||
},
|
||||
{
|
||||
"pattern": r'href="#"',
|
||||
"description": 'Avoid href="#" for elements with a JavaScript click handler.',
|
||||
"exclude": {"static/templates/navbar.hbs"},
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user