diff --git a/src/content/hints/getContextForHint.ts b/src/content/hints/getContextForHint.ts index 3ba3de3e..030245c9 100644 --- a/src/content/hints/getContextForHint.ts +++ b/src/content/hints/getContextForHint.ts @@ -171,28 +171,23 @@ export function getAptContainer(origin: Element) { if (!(current instanceof HTMLElement) || current.shadowRoot) { current = current.parentNode; - continue; - } - - const { display } = getCachedStyle(current); - - if ( - current.matches("thead, tbody, tfoot, caption, colgroup, col, tr, th, td") - ) { - current = current.closest("table") ?? current.parentElement; - continue; - } - - if (current.tagName === "TABLE" || display.startsWith("table")) { - current = current.parentElement; - continue; - } - - if (current.tagName !== "DETAILS" && display !== "contents") { - return current; + } else { + const { display } = getCachedStyle(current); + + if ( + current.matches( + "thead, tbody, tfoot, caption, colgroup, col, tr, th, td" + ) + ) { + current = current.closest("table") ?? current.parentElement; + } else if (current.tagName === "TABLE" || display.startsWith("table")) { + current = current.parentElement; + } else if (current.tagName !== "DETAILS" && display !== "contents") { + return current; + } else { + current = current.parentElement; + } } - - current = current.parentElement; } return document.body;