about summary refs log tree commit diff
path: root/src/librustdoc/html/static/source-script.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html/static/source-script.js')
-rw-r--r--src/librustdoc/html/static/source-script.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/source-script.js b/src/librustdoc/html/static/source-script.js
index 5c39e760f44..6805f2a266f 100644
--- a/src/librustdoc/html/static/source-script.js
+++ b/src/librustdoc/html/static/source-script.js
@@ -141,8 +141,8 @@ function createSourceSidebar() {
 
     main.insertBefore(sidebar, main.firstChild);
     // Focus on the current file in the source files sidebar.
-    var selected_elems = Array.prototype.slice.call(sidebar.getElementsByClassName("selected"));
-    if (selected_elems.length > 0) {
-        selected_elems[0].focus();
+    var selected_elem = sidebar.getElementsByClassName("selected")[0];
+    if (typeof selected_elem !== "undefined") {
+        selected_elem.focus();
     }
 }