mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Use classList.replace
This commit is contained in:
parent
f45b8c9845
commit
e9addc90ca
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@ -45,7 +45,7 @@ Please follow this Issue template to provide relevant information, such as sourc
|
||||
```
|
||||
|
||||
### Package dependencies Information
|
||||
<!-- Paste output from `npm ls --depth 0` in Hexo root dirctory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
|
||||
<!-- Paste output from `npm ls --depth 0` in Hexo root directory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/question.md
vendored
2
.github/ISSUE_TEMPLATE/question.md
vendored
@ -45,7 +45,7 @@ Please follow this Issue template to provide relevant information, such as sourc
|
||||
```
|
||||
|
||||
### Package dependencies Information
|
||||
<!-- Paste output from `npm ls --depth 0` in Hexo root dirctory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
|
||||
<!-- Paste output from `npm ls --depth 0` in Hexo root directory (粘贴在 Hexo 根目录下 `npm ls --depth 0` 输出的信息) -->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
@ -59,8 +59,7 @@ NexT.boot.registerEvents = function() {
|
||||
translateY: [0, -20],
|
||||
complete : () => {
|
||||
// Prevent adding TOC to Overview if Overview was selected when close & open sidebar.
|
||||
sidebar.classList.remove(activeClassName[1 - index]);
|
||||
sidebar.classList.add(activeClassName[index]);
|
||||
sidebar.classList.replace(activeClassName[1 - index], activeClassName[index]);
|
||||
window.anime({
|
||||
duration,
|
||||
targets : panel[index],
|
||||
|
||||
@ -6,6 +6,14 @@ HTMLElement.prototype.wrap = function(wrapper) {
|
||||
wrapper.appendChild(this);
|
||||
};
|
||||
|
||||
// https://caniuse.com/#feat=mdn-api_element_classlist_replace
|
||||
if (typeof DOMTokenList.prototype.replace !== 'function') {
|
||||
DOMTokenList.prototype.replace = function(remove, add) {
|
||||
this.remove(remove);
|
||||
this.add(add);
|
||||
};
|
||||
}
|
||||
|
||||
NexT.utils = {
|
||||
|
||||
/**
|
||||
@ -66,9 +74,7 @@ NexT.utils = {
|
||||
document.querySelectorAll('figure.highlight').forEach(element => {
|
||||
element.querySelectorAll('.code .line span').forEach(span => {
|
||||
span.classList.forEach(name => {
|
||||
// https://caniuse.com/#feat=mdn-api_element_classlist_replace
|
||||
span.classList.remove(name);
|
||||
span.classList.add(`hljs-${name}`);
|
||||
span.classList.replace(name, `hljs-${name}`);
|
||||
});
|
||||
});
|
||||
if (!CONFIG.copycode) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user