Skip to content

Commit

Permalink
Rollup merge of rust-lang#58336 - GuillaumeGomez:fix-search-results-i…
Browse files Browse the repository at this point in the history
…nteractions, r=oli-obk

Fix search results interactions

The bug is visible when you search for "none": the second tab is empty and therefore it messes with the classes. Then when you try to use arrows on the third tab, it just crashes (because only 2 "search-results" are present and you're on tab 3).

r? @QuietMisdreavus
  • Loading branch information
kennytm committed Feb 20, 2019
2 parents 120e9cb + 69d948d commit d22bb1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ if (!DOMTokenList.prototype.remove) {
var actives = [[], [], []];
// "current" is used to know which tab we're looking into.
var current = 0;
onEachLazy(document.getElementsByClassName("search-results"), function(e) {
onEachLazy(document.getElementById("results").childNodes, function(e) {
onEachLazy(e.getElementsByClassName("highlighted"), function(e) {
actives[current].push(e);
});
Expand All @@ -1213,7 +1213,7 @@ if (!DOMTokenList.prototype.remove) {
removeClass(actives[currentTab][0], "highlighted");
} else if (e.which === 40) { // down
if (!actives[currentTab].length) {
var results = document.getElementsByClassName("search-results");
var results = document.getElementById("results").childNodes;
if (results.length > 0) {
var res = results[currentTab].getElementsByClassName("result");
if (res.length > 0) {
Expand Down

0 comments on commit d22bb1a

Please sign in to comment.