mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +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:
@@ -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