about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/scrape-examples.js
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-07 22:41:39 +0000
committerbors <bors@rust-lang.org>2022-05-07 22:41:39 +0000
commite612ce9ce50182fb33a5186fbb39cdd5d4534f1f (patch)
tree387c7e6345267016414d6dbd5eecf6773733efb8 /src/librustdoc/html/static/js/scrape-examples.js
parentea92b08383b718e79317b29470cb244c48557cd5 (diff)
parent20ade86456c69e7987153006ed85108a3493b3fd (diff)
downloadrust-e612ce9ce50182fb33a5186fbb39cdd5d4534f1f.tar.gz
rust-e612ce9ce50182fb33a5186fbb39cdd5d4534f1f.zip
Auto merge of #96824 - matthiaskrgr:rollup-silw3ki, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #96336 (Link to correct `as_mut` in docs for `pointer::as_ref`)
 - #96586 (Add aliases for std::fs::canonicalize)
 - #96667 (Add regression test)
 - #96671 (Remove hard links from `env::current_exe` security example)
 - #96726 (Add regression and bug tests)
 - #96756 (Enable compiler-docs by default for `compiler`, `codegen`, and `tools` profiles)
 - #96757 (Don't constantly rebuild clippy on `x test src/tools/clippy`.)
 - #96769 (Remove `adx_target_feature` feature from active features list)
 - #96777 (Make the test `check-pass` not to produce a JSON file)
 - #96822 (Enforce quote rule for JS source code)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc/html/static/js/scrape-examples.js')
-rw-r--r--src/librustdoc/html/static/js/scrape-examples.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/librustdoc/html/static/js/scrape-examples.js b/src/librustdoc/html/static/js/scrape-examples.js
index 544bced4c5a..408b7e19fea 100644
--- a/src/librustdoc/html/static/js/scrape-examples.js
+++ b/src/librustdoc/html/static/js/scrape-examples.js
@@ -8,7 +8,7 @@
 
     // Scroll code block to the given code location
     function scrollToLoc(elt, loc) {
-        const lines = elt.querySelector('.line-numbers');
+        const lines = elt.querySelector(".line-numbers");
         let scrollOffset;
 
         // If the block is greater than the size of the viewer,
@@ -32,16 +32,16 @@
     function updateScrapedExample(example) {
         const locs = JSON.parse(example.attributes.getNamedItem("data-locs").textContent);
         let locIndex = 0;
-        const highlights = Array.prototype.slice.call(example.querySelectorAll('.highlight'));
-        const link = example.querySelector('.scraped-example-title a');
+        const highlights = Array.prototype.slice.call(example.querySelectorAll(".highlight"));
+        const link = example.querySelector(".scraped-example-title a");
 
         if (locs.length > 1) {
             // Toggle through list of examples in a given file
             const onChangeLoc = changeIndex => {
-                removeClass(highlights[locIndex], 'focus');
+                removeClass(highlights[locIndex], "focus");
                 changeIndex();
                 scrollToLoc(example, locs[locIndex][0]);
-                addClass(highlights[locIndex], 'focus');
+                addClass(highlights[locIndex], "focus");
 
                 const url = locs[locIndex][1];
                 const title = locs[locIndex][2];
@@ -50,24 +50,24 @@
                 link.innerHTML = title;
             };
 
-            example.querySelector('.prev')
-                .addEventListener('click', () => {
+            example.querySelector(".prev")
+                .addEventListener("click", () => {
                     onChangeLoc(() => {
                         locIndex = (locIndex - 1 + locs.length) % locs.length;
                     });
                 });
 
-            example.querySelector('.next')
-                .addEventListener('click', () => {
+            example.querySelector("next")
+                .addEventListener("click", () => {
                     onChangeLoc(() => {
                         locIndex = (locIndex + 1) % locs.length;
                     });
                 });
         }
 
-        const expandButton = example.querySelector('.expand');
+        const expandButton = example.querySelector(".expand");
         if (expandButton) {
-            expandButton.addEventListener('click', () => {
+            expandButton.addEventListener("click", () => {
                 if (hasClass(example, "expanded")) {
                     removeClass(example, "expanded");
                     scrollToLoc(example, locs[0][0]);
@@ -81,19 +81,19 @@
         scrollToLoc(example, locs[0][0]);
     }
 
-    const firstExamples = document.querySelectorAll('.scraped-example-list > .scraped-example');
+    const firstExamples = document.querySelectorAll(".scraped-example-list > .scraped-example");
     onEachLazy(firstExamples, updateScrapedExample);
-    onEachLazy(document.querySelectorAll('.more-examples-toggle'), toggle => {
+    onEachLazy(document.querySelectorAll(".more-examples-toggle"), toggle => {
         // Allow users to click the left border of the <details> section to close it,
         // since the section can be large and finding the [+] button is annoying.
-        onEachLazy(toggle.querySelectorAll('.toggle-line, .hide-more'), button => {
-            button.addEventListener('click', () => {
+        onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"), button => {
+            button.addEventListener("click", () => {
                 toggle.open = false;
             });
         });
 
-        const moreExamples = toggle.querySelectorAll('.scraped-example');
-        toggle.querySelector('summary').addEventListener('click', () => {
+        const moreExamples = toggle.querySelectorAll(".scraped-example");
+        toggle.querySelector("summary").addEventListener("click", () => {
             // Wrapping in setTimeout ensures the update happens after the elements are actually
             // visible. This is necessary since updateScrapedExample calls scrollToLoc which
             // depends on offsetHeight, a property that requires an element to be visible to