Skip to content

Commit 9520641

Browse files
authored
Rollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle
Use "strict" mode in JS scripts Part of #93058. r? `@notriddle`
2 parents 34bf620 + 1e204dd commit 9520641

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/* global onEach, onEachLazy, removeClass */
88
/* global switchTheme, useSystemTheme */
99

10+
"use strict";
11+
1012
if (!String.prototype.startsWith) {
1113
String.prototype.startsWith = function(searchString, position) {
1214
position = position || 0;
@@ -292,15 +294,12 @@ function loadCss(cssFileName) {
292294
}
293295

294296
(function() {
295-
"use strict";
296-
297297
function loadScript(url) {
298298
const script = document.createElement('script');
299299
script.src = url;
300300
document.head.append(script);
301301
}
302302

303-
304303
getSettingsButton().onclick = event => {
305304
event.preventDefault();
306305
loadScript(window.settingsJS);

src/librustdoc/html/static/js/scrape-examples.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
/* eslint prefer-arrow-callback: "error" */
55
/* global addClass, hasClass, removeClass, onEachLazy */
66

7+
"use strict";
8+
79
(function () {
810
// Number of lines shown when code viewer is not expanded
911
const MAX_LINES = 10;

src/librustdoc/html/static/js/search.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
66
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
77

8-
(function () {
8+
"use strict";
9+
10+
(function() {
911
// This mapping table should match the discriminants of
1012
// `rustdoc::formats::item_type::ItemType` type in Rust.
1113
const itemTypes = [

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

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
88
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */
99

10+
"use strict";
11+
1012
(function () {
1113
const isSettingsPage = window.location.pathname.endsWith("/settings.html");
1214

src/librustdoc/html/static/js/source-script.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
// Local js definitions:
1010
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
1111
/* global updateLocalStorage */
12-
(function () {
12+
13+
"use strict";
14+
15+
(function() {
1316

1417
function getCurrentFilePath() {
1518
const parts = window.location.pathname.split("/");

src/librustdoc/html/static/js/storage.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/* eslint prefer-const: "error" */
44
/* eslint prefer-arrow-callback: "error" */
55

6+
"use strict";
7+
68
const darkThemes = ["dark", "ayu"];
79
window.currentTheme = document.getElementById("themeStyle");
810
window.mainTheme = document.getElementById("mainThemeStyle");

0 commit comments

Comments
 (0)