Skip to content

Commit

Permalink
Rollup merge of #96635 - GuillaumeGomez:js-script-mode, r=notriddle
Browse files Browse the repository at this point in the history
Use "strict" mode in JS scripts

Part of #93058.

r? `@notriddle`
  • Loading branch information
matthiaskrgr authored May 5, 2022
2 parents 34bf620 + 1e204dd commit 9520641
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/* global onEach, onEachLazy, removeClass */
/* global switchTheme, useSystemTheme */

"use strict";

if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
Expand Down Expand Up @@ -292,15 +294,12 @@ function loadCss(cssFileName) {
}

(function() {
"use strict";

function loadScript(url) {
const script = document.createElement('script');
script.src = url;
document.head.append(script);
}


getSettingsButton().onclick = event => {
event.preventDefault();
loadScript(window.settingsJS);
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/js/scrape-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/* eslint prefer-arrow-callback: "error" */
/* global addClass, hasClass, removeClass, onEachLazy */

"use strict";

(function () {
// Number of lines shown when code viewer is not expanded
const MAX_LINES = 10;
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */

(function () {
"use strict";

(function() {
// This mapping table should match the discriminants of
// `rustdoc::formats::item_type::ItemType` type in Rust.
const itemTypes = [
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/* global addClass, removeClass, onEach, onEachLazy, NOT_DISPLAYED_ID */
/* global MAIN_ID, getVar, getSettingsButton, switchDisplayedElement, getNotDisplayedElem */

"use strict";

(function () {
const isSettingsPage = window.location.pathname.endsWith("/settings.html");

Expand Down
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// Local js definitions:
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage */
(function () {

"use strict";

(function() {

function getCurrentFilePath() {
const parts = window.location.pathname.split("/");
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/* eslint prefer-const: "error" */
/* eslint prefer-arrow-callback: "error" */

"use strict";

const darkThemes = ["dark", "ayu"];
window.currentTheme = document.getElementById("themeStyle");
window.mainTheme = document.getElementById("mainThemeStyle");
Expand Down

0 comments on commit 9520641

Please sign in to comment.