Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve JS code a bit by avoid erasing all event handlers
  • Loading branch information
GuillaumeGomez committed Dec 22, 2019
commit 4ce2384501833127fa3c9e995240d78b07f0ab2f
9 changes: 5 additions & 4 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ function getSearchElement() {
}

function handleEscape(ev) {
debugger;
var help = getHelpElement();
var search = getSearchElement();
hideModal();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand All @@ -452,7 +453,7 @@ function getSearchElement() {
expandSection(a.hash.replace(/^#/, ""));
}
}
};
});

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