about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/source-script.js
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-05 02:49:16 +0000
committerbors <bors@rust-lang.org>2022-05-05 02:49:16 +0000
commit7d3e03666a93bd2b0f78b3933f9305832af771a5 (patch)
tree94da1941a3795bd5faf7ed469b1d2edc9bf9c1d0 /src/librustdoc/html/static/js/source-script.js
parentbdcb6a99e853732f8ec050ae4986aa3af51d44c5 (diff)
parentade123275db92898b13faffea08893f0a6737ff4 (diff)
Auto merge of #96720 - JohnTitor:rollup-9jaaekr, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #96603 (Enable full revision in const generics ui tests)
 - #96616 (Relax memory ordering used in `min_stack`)
 - #96619 (Relax memory ordering used in SameMutexCheck)
 - #96628 (Stabilize `bool::then_some`)
 - #96658 (Move callback to the () => {} syntax.)
 - #96677 (Add more tests for label-break-value)
 - #96697 (Enable tracing for all queries)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc/html/static/js/source-script.js')
-rw-r--r--src/librustdoc/html/static/js/source-script.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js
index 6aee0da69f8..290bf40a8f5 100644
--- a/src/librustdoc/html/static/js/source-script.js
+++ b/src/librustdoc/html/static/js/source-script.js
@@ -1,6 +1,7 @@
 /* eslint-env es6 */
 /* eslint no-var: "error" */
 /* eslint prefer-const: "error" */
+/* eslint prefer-arrow-callback: "error" */
 
 // From rust:
 /* global search, sourcesIndex */
@@ -8,7 +9,7 @@
 // Local js definitions:
 /* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
 /* global updateLocalStorage */
-(function() {
+(function () {
 
 function getCurrentFilePath() {
     const parts = window.location.pathname.split("/");
@@ -32,7 +33,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
 
     fullPath += elem["name"] + "/";
 
-    name.onclick = function() {
+    name.onclick = () => {
         if (hasClass(this, "expand")) {
             removeClass(this, "expand");
         } else {
@@ -134,7 +135,7 @@ function createSourceSidebar() {
     title.className = "title";
     title.innerText = "Files";
     sidebar.appendChild(title);
-    Object.keys(sourcesIndex).forEach(function(key) {
+    Object.keys(sourcesIndex).forEach(key => {
         sourcesIndex[key].name = key;
         hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "",
                                       currentFile, hasFoundFile);
@@ -175,8 +176,8 @@ function highlightSourceLines(match) {
     if (x) {
         x.scrollIntoView();
     }
-    onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
-        onEachLazy(e.getElementsByTagName("span"), function(i_e) {
+    onEachLazy(document.getElementsByClassName("line-numbers"), e => {
+        onEachLazy(e.getElementsByTagName("span"), i_e => {
             removeClass(i_e, "line-highlighted");
         });
     });
@@ -189,10 +190,10 @@ function highlightSourceLines(match) {
     }
 }
 
-const handleSourceHighlight = (function() {
+const handleSourceHighlight = (function () {
     let prev_line_id = 0;
 
-    const set_fragment = function(name) {
+    const set_fragment = name => {
         const x = window.scrollX,
             y = window.scrollY;
         if (browserSupportsHistoryApi()) {
@@ -205,7 +206,7 @@ const handleSourceHighlight = (function() {
         window.scrollTo(x, y);
     };
 
-    return function(ev) {
+    return ev => {
         let cur_line_id = parseInt(ev.target.id, 10);
         ev.preventDefault();
 
@@ -226,14 +227,14 @@ const handleSourceHighlight = (function() {
     };
 }());
 
-window.addEventListener("hashchange", function() {
+window.addEventListener("hashchange", () => {
     const match = window.location.hash.match(lineNumbersRegex);
     if (match) {
         return highlightSourceLines(match);
     }
 });
 
-onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
+onEachLazy(document.getElementsByClassName("line-numbers"), el => {
     el.addEventListener("click", handleSourceHighlight);
 });