From ccabd4eedf982e3fcf7f730efc8ff1c7b0ee88f7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 May 2021 13:56:15 +0200 Subject: Fix eslint errors --- src/librustdoc/html/static/source-script.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/librustdoc/html/static/source-script.js') diff --git a/src/librustdoc/html/static/source-script.js b/src/librustdoc/html/static/source-script.js index 81cf437c7db..4d9a59f836b 100644 --- a/src/librustdoc/html/static/source-script.js +++ b/src/librustdoc/html/static/source-script.js @@ -2,7 +2,8 @@ /* global search, sourcesIndex */ // Local js definitions: -/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */ +/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, searchState */ +/* global updateLocalStorage */ (function() { function getCurrentFilePath() { @@ -153,7 +154,7 @@ function createSourceSidebar() { var lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/; -function highlightSourceLines(match, ev) { +function highlightSourceLines(scrollTo, match) { if (typeof match === "undefined") { match = window.location.hash.match(lineNumbersRegex); } @@ -174,7 +175,7 @@ function highlightSourceLines(match, ev) { if (!elem) { return; } - if (!ev) { + if (scrollTo) { var x = document.getElementById(from); if (x) { x.scrollIntoView(); @@ -202,7 +203,7 @@ var handleSourceHighlight = (function() { y = window.scrollY; if (searchState.browserSupportsHistoryApi()) { history.replaceState(null, null, "#" + name); - highlightSourceLines(); + highlightSourceLines(true); } else { location.replace("#" + name); } @@ -234,7 +235,7 @@ var handleSourceHighlight = (function() { window.addEventListener("hashchange", function() { var match = window.location.hash.match(lineNumbersRegex); if (match) { - return highlightSourceLines(match, ev); + return highlightSourceLines(false, match); } }); @@ -242,7 +243,7 @@ onEachLazy(document.getElementsByClassName("line-numbers"), function(el) { el.addEventListener("click", handleSourceHighlight); }); -highlightSourceLines(); +highlightSourceLines(true); window.createSourceSidebar = createSourceSidebar; })(); -- cgit 1.4.1-3-g733a5