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.

docs: Avoid exceptions in scrollToHash() in Safari.

Kunal Sharmac3173b979eb4
diff --git a/web/src/portico/help.js b/web/src/portico/help.js
index 6c39044f69f..2c93b4e2e23 100644
--- a/web/src/portico/help.js
+++ b/web/src/portico/help.js
@@ -123,11 +123,11 @@ function render_code_sections() {
function scrollToHash(simplebar) {
const hash = window.location.hash;
const scrollbar = simplebar.getScrollElement();
- if (hash !== "" && $(hash).length > 0) {
- const position = $(hash).position().top - $(scrollbar.firstChild).position().top;
+ const $scroll_target = $(CSS.escape(hash));
+ if (hash !== "" && $scroll_target.length > 0) {
+ const position = $scroll_target.position().top - $(scrollbar.firstChild).position().top;
// Preserve a reference to the scroll target, so it is not lost (and the highlight
// along with it) when the page is updated via fetch
- const $scroll_target = $(hash);
$scroll_target.addClass("scroll-target");
scrollbar.scrollTop = position;
} else {