Fix eslint errors
This updates the ecmaVersion due to the ?? nullish coalescing operator.
This commit is contained in:
parent
20eea0b41e
commit
54d8d37b77
2 changed files with 13 additions and 13 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
"require": "readonly"
|
"require": "readonly"
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018,
|
"ecmaVersion": 2021,
|
||||||
"requireConfigFile": false,
|
"requireConfigFile": false,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* global default_theme, hljs, ClipboardJS */
|
/* global default_theme, default_dark_theme, default_light_theme, hljs, ClipboardJS */
|
||||||
|
|
||||||
// Fix back button cache problem
|
// Fix back button cache problem
|
||||||
window.onunload = function() { };
|
window.onunload = function() { };
|
||||||
|
|
@ -329,11 +329,11 @@ aria-label="Show hidden lines"></button>';
|
||||||
themePopup.querySelectorAll('.theme-selected').forEach(function(el) {
|
themePopup.querySelectorAll('.theme-selected').forEach(function(el) {
|
||||||
el.classList.remove('theme-selected');
|
el.classList.remove('theme-selected');
|
||||||
});
|
});
|
||||||
const selected = get_saved_theme() ?? "default_theme";
|
const selected = get_saved_theme() ?? 'default_theme';
|
||||||
var element = themePopup.querySelector("button#" + selected);
|
let element = themePopup.querySelector('button#' + selected);
|
||||||
if (element === null) {
|
if (element === null) {
|
||||||
// Fall back in case there is no "Default" item.
|
// Fall back in case there is no "Default" item.
|
||||||
element = themePopup.querySelector("button#" + get_theme());
|
element = themePopup.querySelector('button#' + get_theme());
|
||||||
}
|
}
|
||||||
element.classList.add('theme-selected');
|
element.classList.add('theme-selected');
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +345,7 @@ aria-label="Show hidden lines"></button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_saved_theme() {
|
function get_saved_theme() {
|
||||||
var theme = null;
|
let theme = null;
|
||||||
try {
|
try {
|
||||||
theme = localStorage.getItem('mdbook-theme');
|
theme = localStorage.getItem('mdbook-theme');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -359,14 +359,14 @@ aria-label="Show hidden lines"></button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_theme() {
|
function get_theme() {
|
||||||
var theme = get_saved_theme();
|
const theme = get_saved_theme();
|
||||||
if (theme === null || theme === undefined || !themeIds.includes(theme)) {
|
if (theme === null || theme === undefined || !themeIds.includes(theme)) {
|
||||||
if (typeof default_dark_theme === 'undefined') {
|
if (typeof default_dark_theme === 'undefined') {
|
||||||
// A customized index.hbs might not define this, so fall back to
|
// A customized index.hbs might not define this, so fall back to
|
||||||
// old behavior of determining the default on page load.
|
// old behavior of determining the default on page load.
|
||||||
return default_theme;
|
return default_theme;
|
||||||
}
|
}
|
||||||
return window.matchMedia("(prefers-color-scheme: dark)").matches
|
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
? default_dark_theme
|
? default_dark_theme
|
||||||
: default_light_theme;
|
: default_light_theme;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -374,7 +374,7 @@ aria-label="Show hidden lines"></button>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousTheme = default_theme;
|
let previousTheme = default_theme;
|
||||||
function set_theme(theme, store = true) {
|
function set_theme(theme, store = true) {
|
||||||
let ace_theme;
|
let ace_theme;
|
||||||
|
|
||||||
|
|
@ -420,8 +420,8 @@ aria-label="Show hidden lines"></button>';
|
||||||
updateThemeSelected();
|
updateThemeSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = window.matchMedia("(prefers-color-scheme: dark)");
|
const query = window.matchMedia('(prefers-color-scheme: dark)');
|
||||||
query.onchange = function(event) {
|
query.onchange = function() {
|
||||||
set_theme(get_theme(), false);
|
set_theme(get_theme(), false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -445,7 +445,7 @@ aria-label="Show hidden lines"></button>';
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (theme === "default_theme" || theme == null) {
|
if (theme === 'default_theme' || theme === null) {
|
||||||
delete_saved_theme();
|
delete_saved_theme();
|
||||||
set_theme(get_theme(), false);
|
set_theme(get_theme(), false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue