Skip to content

Commit e114392

Browse files
committed
Updated format
Signed-off-by: Moulik Aggarwal <qwertymoulik@gmail.com>
1 parent 69b6020 commit e114392

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

apps/docs/src/components/override-components/TableOfContents/starlight-toc.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ export class StarlightTOC extends HTMLElement {
4848
): HTMLHeadingElement | null => {
4949
if (!el) return null;
5050
const origin = el;
51-
while (el) {
52-
if (isHeading(el)) return el;
53-
// Assign the previous sibling’s last, most deeply nested child to el.
54-
el = el.previousElementSibling;
55-
while (el?.lastElementChild) {
56-
el = el.lastElementChild;
51+
let current: Element | null = el;
52+
while (current) {
53+
if (isHeading(current)) return current;
54+
// Assign the previous sibling’s last, most deeply nested child to current.
55+
current = current.previousElementSibling;
56+
while (current?.lastElementChild) {
57+
current = current.lastElementChild;
5758
}
5859
// Look for headings amongst siblings.
59-
const h = getElementHeading(el);
60+
const h = getElementHeading(current);
6061
if (h) return h;
6162
}
6263
// Walk back up the parent.

0 commit comments

Comments
 (0)