From 6d7e2135f15eeb9a586ef97bb6a7744e5a936777 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 17 Jan 2023 17:22:05 -0700 Subject: [PATCH 1/2] rustdoc: remove function `handleClick` that's only used once --- src/librustdoc/html/static/js/main.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index f52229d8095..4d604a21496 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -803,15 +803,10 @@ function loadCss(cssUrl) { } }); - function handleClick(id, f) { - const elem = document.getElementById(id); - if (elem) { - elem.addEventListener("click", f); - } + const mainElem = document.getElementById(MAIN_ID); + if (mainElem) { + mainElem.addEventListener("click", hideSidebar); } - handleClick(MAIN_ID, () => { - hideSidebar(); - }); onEachLazy(document.querySelectorAll("a[href^='#']"), el => { // For clicks on internal links ( tags with a hash property), we expand the section we're From 708b529f314cc5b126adc2c131dc0d0231db41dc Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 17 Jan 2023 17:54:58 -0700 Subject: [PATCH 2/2] rustdoc: stop using deprecated `window.event` when there's an `ev` param --- src/librustdoc/html/static/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 4d604a21496..9ceeeb5ae8f 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -940,7 +940,7 @@ function loadCss(cssUrl) { return; } if (!this.NOTABLE_FORCE_VISIBLE && - !elemIsInParent(event.relatedTarget, window.CURRENT_NOTABLE_ELEMENT)) { + !elemIsInParent(ev.relatedTarget, window.CURRENT_NOTABLE_ELEMENT)) { hideNotable(true); } };