Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sphinx_fuma/static/fuma.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
.map(function (item) {
var href = item.querySelector("a").getAttribute("href") || "";
var anchor = href.charAt(0) === "#" ? document.getElementById(decodeURIComponent(href.slice(1))) : null;
var heading = anchor && (anchor.matches("h1, h2, h3, h4, h5, h6") ? anchor : anchor.querySelector("h1, h2, h3, h4, h5, h6"));
var heading = anchor && (anchor.matches("h1, h2, h3, h4, h5, h6") ? anchor : anchor.querySelector("h1, h2, h3, h4, h5, h6") || anchor);
return heading ? { item: item, heading: heading } : null;
})
.filter(Boolean);
Expand Down
1 change: 1 addition & 0 deletions sphinx_fuma/tests/test_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def test_toc_rail_is_an_svg_with_track_and_thumb(self, built):
def test_toc_scroll_spy_observes_headings_across_the_viewport(self, built):
script = (built / "_static" / "fuma.js").read_text()
assert 'anchor.querySelector("h1, h2, h3, h4, h5, h6")' in script
assert 'anchor.querySelector("h1, h2, h3, h4, h5, h6") || anchor' in script
assert "threshold: 0.9" in script
assert "rootMargin:" not in script

Expand Down