Skip to content

Commit d2d0223

Browse files
guludoJonathan Corbet
authored andcommitted
docs/sphinx: Fix TOC scroll hack for the home page
When on the documentation home page, there won't be any ".current" element since no entry from the TOC was selected yet. That results in a javascript error. Fix that by only trying to set the scrollTop if we have matches for current entries. Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/20240123162157.61819-2-gustavo.sousa@intel.com
1 parent 6613476 commit d2d0223

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Documentation/sphinx/templates/kernel-toc.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ <h3 class="kernel-toc-contents">Contents</h3>
1212
<script type="text/javascript"> <!--
1313
var sbar = document.getElementsByClassName("sphinxsidebar")[0];
1414
let currents = document.getElementsByClassName("current")
15-
sbar.scrollTop = currents[currents.length - 1].offsetTop;
15+
if (currents.length) {
16+
sbar.scrollTop = currents[currents.length - 1].offsetTop;
17+
}
1618
--> </script>

0 commit comments

Comments
 (0)