Skip to content

Commit 5ede940

Browse files
committed
Auto merge of #115669 - GuillaumeGomez:js-anonymous-functions, r=notriddle
rustdoc: Change syntax for anonymous functions set in JS This function is not very useful in itself but it slightly reduces the JS size so it's always that I suppose... No changes in behaviour. r? `@notriddle`
2 parents b0b8c52 + 6ec8d71 commit 5ede940

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/librustdoc/html/static/js/main.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -852,14 +852,14 @@ function preLoadCss(cssUrl) {
852852
window.CURRENT_TOOLTIP_ELEMENT = wrapper;
853853
window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE = e;
854854
clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT);
855-
wrapper.onpointerenter = function(ev) {
855+
wrapper.onpointerenter = ev => {
856856
// If this is a synthetic touch event, ignore it. A click event will be along shortly.
857857
if (ev.pointerType !== "mouse") {
858858
return;
859859
}
860860
clearTooltipHoverTimeout(e);
861861
};
862-
wrapper.onpointerleave = function(ev) {
862+
wrapper.onpointerleave = ev => {
863863
// If this is a synthetic touch event, ignore it. A click event will be along shortly.
864864
if (ev.pointerType !== "mouse") {
865865
return;
@@ -963,38 +963,38 @@ function preLoadCss(cssUrl) {
963963
}
964964

965965
onEachLazy(document.getElementsByClassName("tooltip"), e => {
966-
e.onclick = function() {
967-
this.TOOLTIP_FORCE_VISIBLE = this.TOOLTIP_FORCE_VISIBLE ? false : true;
968-
if (window.CURRENT_TOOLTIP_ELEMENT && !this.TOOLTIP_FORCE_VISIBLE) {
966+
e.onclick = () => {
967+
e.TOOLTIP_FORCE_VISIBLE = e.TOOLTIP_FORCE_VISIBLE ? false : true;
968+
if (window.CURRENT_TOOLTIP_ELEMENT && !e.TOOLTIP_FORCE_VISIBLE) {
969969
hideTooltip(true);
970970
} else {
971-
showTooltip(this);
971+
showTooltip(e);
972972
window.CURRENT_TOOLTIP_ELEMENT.setAttribute("tabindex", "0");
973973
window.CURRENT_TOOLTIP_ELEMENT.focus();
974974
window.CURRENT_TOOLTIP_ELEMENT.onblur = tooltipBlurHandler;
975975
}
976976
return false;
977977
};
978-
e.onpointerenter = function(ev) {
978+
e.onpointerenter = ev => {
979979
// If this is a synthetic touch event, ignore it. A click event will be along shortly.
980980
if (ev.pointerType !== "mouse") {
981981
return;
982982
}
983-
setTooltipHoverTimeout(this, true);
983+
setTooltipHoverTimeout(e, true);
984984
};
985-
e.onpointermove = function(ev) {
985+
e.onpointermove = ev => {
986986
// If this is a synthetic touch event, ignore it. A click event will be along shortly.
987987
if (ev.pointerType !== "mouse") {
988988
return;
989989
}
990-
setTooltipHoverTimeout(this, true);
990+
setTooltipHoverTimeout(e, true);
991991
};
992-
e.onpointerleave = function(ev) {
992+
e.onpointerleave = ev => {
993993
// If this is a synthetic touch event, ignore it. A click event will be along shortly.
994994
if (ev.pointerType !== "mouse") {
995995
return;
996996
}
997-
if (!this.TOOLTIP_FORCE_VISIBLE &&
997+
if (!e.TOOLTIP_FORCE_VISIBLE &&
998998
!elemIsInParent(ev.relatedTarget, window.CURRENT_TOOLTIP_ELEMENT)) {
999999
// Tooltip pointer leave gesture:
10001000
//
@@ -1139,7 +1139,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
11391139
*
11401140
* Pass "true" to reset focus for tooltip popovers.
11411141
*/
1142-
window.hideAllModals = function(switchFocus) {
1142+
window.hideAllModals = switchFocus => {
11431143
hideSidebar();
11441144
window.hidePopoverMenus();
11451145
hideTooltip(switchFocus);
@@ -1148,7 +1148,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
11481148
/**
11491149
* Hide all the popover menus.
11501150
*/
1151-
window.hidePopoverMenus = function() {
1151+
window.hidePopoverMenus = () => {
11521152
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
11531153
elem.style.display = "none";
11541154
});

src/librustdoc/html/static/js/settings.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
if (settingValue !== null) {
6060
toggle.checked = settingValue === "true";
6161
}
62-
toggle.onchange = function() {
63-
changeSetting(this.id, this.checked);
62+
toggle.onchange = () => {
63+
changeSetting(toggle.id, toggle.checked);
6464
};
6565
});
6666
onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"), elem => {
@@ -224,14 +224,14 @@
224224

225225
if (isSettingsPage) {
226226
// We replace the existing "onclick" callback to do nothing if clicked.
227-
getSettingsButton().onclick = function(event) {
227+
getSettingsButton().onclick = event => {
228228
event.preventDefault();
229229
};
230230
} else {
231231
// We replace the existing "onclick" callback.
232232
const settingsButton = getSettingsButton();
233233
const settingsMenu = document.getElementById("settings");
234-
settingsButton.onclick = function(event) {
234+
settingsButton.onclick = event => {
235235
if (elemIsInParent(event.target, settingsMenu)) {
236236
return;
237237
}

0 commit comments

Comments
 (0)