// Theme 12 — Navigation + page landmarks (statically-checkable slice). import type { Doc, El } from "../parse/html.js"; import { attr, descendants, elementsByTag, hasAttr, hasBoundAttr, hasDynamicSpread } from "../parse/html.js"; import { isIntrinsic } from "../parse/jsx-bridge.js"; import { type Rule, type RuleFinding, shellBodyInjected } from "./rule.js"; // JSX/SFC: a child component or a `{children}`/`{expr}` child may inject the
at // runtime (a Next.js layout supplies
via {children}). Never assert "no main" then. function contentMaybeInjected(doc: Doc): boolean { if (doc.kind === "html") return false; return doc.elements.some((e) => e.tag === "slot" || (e.tag !== "#fragment" && !isIntrinsic(e.tag))); } /** Visible
/role="main" landmarks (aria-hidden ones don't count). */ function mainLandmarks(doc: Doc): El[] { return doc.elements.filter((e) => { if (attr(e, "aria-hidden") === "true") return false; if (e.tag === "main") return true; return (attr(e, "role") ?? "").trim().toLowerCase() === "main"; }); } /** Visible