Skip to content
Permalink
Browse files

Improve JS code a bit by avoid erasing all event handlers

  • Loading branch information
GuillaumeGomez committed Dec 22, 2019
1 parent 0a440b1 commit 4ce2384501833127fa3c9e995240d78b07f0ab2f
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/librustdoc/html/static/main.js
@@ -324,6 +324,7 @@ function getSearchElement() {
}

function handleEscape(ev) {
debugger;
var help = getHelpElement();
var search = getSearchElement();
hideModal();
@@ -390,8 +391,8 @@ function getSearchElement() {
return null;
}

document.onkeypress = handleShortcut;
document.onkeydown = handleShortcut;
document.addEventListener("keypress", handleShortcut);
document.addEventListener("keydown", handleShortcut);

var handleSourceHighlight = (function() {
var prev_line_id = 0;
@@ -430,7 +431,7 @@ function getSearchElement() {
}
})();

document.onclick = function(ev) {
document.addEventListener("click", function(ev) {
if (hasClass(ev.target, "collapse-toggle")) {
collapseDocs(ev.target, "toggle");
} else if (hasClass(ev.target.parentNode, "collapse-toggle")) {
@@ -452,7 +453,7 @@ function getSearchElement() {
expandSection(a.hash.replace(/^#/, ""));
}
}
};
});

var x = document.getElementsByClassName("version-selector");
if (x.length > 0) {

0 comments on commit 4ce2384

Please sign in to comment.
You can’t perform that action at this time.