Skip to content

ToC incorrectly nested when 4 header selectors are used and headers jump a level #23

Closed
@grafana-dee

Description

@grafana-dee

For the given HTML:

<h1>Depth 1</h1>
<h2>Depth 2</h2>
<h3>Depth 3</h3>
<h4>Depth 4</h4>
<h5>Depth 5</h5>
<h3>Depth 3</h3>
<h2>Depth 2</h2>

And ToCify configured thus:

var toc = $("#toc").tocify({ selectors: "h2, h3, h4, h5" }).data("toc-tocify");

The generated menu will incorrectly nest the second Depth 3 as a sibling to Depth 4, rather than as a sibling to Depth 3.

I believe in the unminised code the bug is on line 411, but I don't know how to fix it.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions