fix(toc): Use data attributes for toc

Partially fixes: #401

Signed-off-by: Khusika Dhamar Gusti <mail@khusika.com>
This commit is contained in:
Khusika Dhamar Gusti 2020-11-27 15:12:26 +07:00
parent 1281b13109
commit 9151f85ce9
6 changed files with 6 additions and 6 deletions

View file

@ -116,7 +116,7 @@
display: none;
margin: .8rem 0;
&[kept=true] {
&[data-kept=true] {
display: block;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -76,7 +76,7 @@
{{- /* Static TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details toc" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>

File diff suppressed because one or more lines are too long

View file

@ -397,7 +397,7 @@ class Theme {
initToc() {
const $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) return;
if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
if (document.getElementById('toc-static').getAttribute('data-kept') || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {
$tocCore.parentElement.removeChild($tocCore);