Skip to content
Snippets Groups Projects

Issue #3474535 by mably: fix generated html with unordered headings

Merged Frank Mably requested to merge issue/toc_js-3474535:3474535-very-odd-behaviour into 3.0.x
+ 12
2
@@ -368,8 +368,18 @@
lastLi = li;
} else if (level < currentLevel) {
while (level < currentLevel) {
currentList = currentList.parentNode.parentNode;
currentLevel = currentList.level;
// Special case where the parent element is the root nav element.
// Can occur when the first heading is not of the highest level.
// See: https://www.drupal.org/project/toc_js/issues/3474535
if (currentList.parentNode.nodeName === 'NAV') {
if (level < currentList.level) {
currentList.level = level;
}
break;
} else {
currentList = currentList.parentNode.parentNode;
currentLevel = currentList.level;
}
}
currentList.appendChild(li);
lastLi = li;
Loading