Repository navigation
DOM Audit
Role. Report layout anomalies within one engine's render: problems a page has even when every browser agrees. A pure function over one capture file; it never touches the page. Module dom-audit, package internal/domaudit.
It is the only module with no spike evidence behind it, so it ships quiet: two checks are report, the rest info, and checks are promoted one at a time.
-
In: one capture (
<engine>-<run>.json). -
Out: a list of
Findings: check id, selector, box, severity, engine. The CLI runsAuditon the baseline's and the engine's run-a capture of every result, and writes both lists into the result'saudit(bundle.go).--no-auditskips it.
The capture is flattened into a walker (every node with its parent), and the seven checks run in reporting order (checks.go). Thresholds are named in audit.go.
| Check | Fires when | Severity |
|---|---|---|
page-horizontal-scroll |
the document is at least 2 px wider than the viewport (docW > vw + 1) |
report |
clipped-text |
a text owner sits inside an overflow: hidden/clip element whose overflow is at least 2 px and less than one viewport (more than a viewport is deliberate hiding, as in image replacement) |
report |
truncated-text |
text cut by an ellipsis or a line clamp (tr) |
info |
overlap-interactive |
two interactive elements overlap by at least 4 px in both directions and neither contains the other | info |
offscreen-interactive |
a visible interactive element lies entirely left of 0 or right of docW
|
info |
zero-size-interactive |
a visible interactive element with its own text but a width or height under 1 px | info |
protrudes-parent |
an element extends at least 4 px beyond a visible parent with a box of its own and overflow: visible, and overlaps a sibling |
info |
protrudes-parent needs the parent to have a box of its own because the capture records no border or background: a parent without a box cannot visibly contain anything, so this is the closest honest approximation.
A finding names its element with the selector a layout-diff cause uses (Layout diff, "Selectors"; internal/selector), built from the walker's parent links when the finding is made: the same five-segment cut, the stop at an id, body or html, the DOM position from nt, escaped tags, ids and classes, and the shadow-host rule (an element inside an open shadow root is named by its outermost host). So a finding and a cause on one element carry the same string.
Findings are sorted report first.
-
audit_test.go: one test per check,TestCleanCaptureHasNoFindings, andTestAuditIsFast(about 5,000 nodes in under 50 ms).selector_test.go: the third of three zero-size buttons isbutton:nth-of-type(3), and every node of a golden capture and of a capture withntgets the same selector aslayoutdiff.Selector. - With browsers,
TestPlantedAuditPages: each check fires on its planted page at the right element.
Nothing found. The spec's "Decisions pending review" now describes the same severities.
-
internal/domaudit/audit.go:Auditand the thresholds -
internal/domaudit/checks.go: the checks, in reporting order -
internal/selector/selector.go: the selector builder findings share with layout-diff causes
This wiki is published from docs/internals/ on main. Edits made here are overwritten on the next publish: change the pages there, in a pull request. The specs are normative; where a page and a spec disagree, the page says what the code does.
Start
Contracts
Capture side
Analysis side
Output
Quality