diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-05-14 13:56:15 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-05-15 13:09:28 +0200 |
| commit | ccabd4eedf982e3fcf7f730efc8ff1c7b0ee88f7 (patch) | |
| tree | 5123b9c3a7c57a0f2860419d21b3c9061c6cba4d /src/librustdoc/html/static/source-script.js | |
| parent | 69b352ef7749825abde2d8f8e31c05f681e61a10 (diff) | |
| download | rust-ccabd4eedf982e3fcf7f730efc8ff1c7b0ee88f7.tar.gz rust-ccabd4eedf982e3fcf7f730efc8ff1c7b0ee88f7.zip | |
Fix eslint errors
Diffstat (limited to 'src/librustdoc/html/static/source-script.js')
| -rw-r--r-- | src/librustdoc/html/static/source-script.js | 13 |
1 files changed, 7 insertions, 6 deletions
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; })(); |
