You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parser: a page body without <html> (empty, text, JSON) makes document.head throw; every DOM rule reports a bogus 'Rule error' fail #1270
A page whose body has no <html> element gives linkedom a document with documentElement === null. That covers an empty 200, whitespace only, a comment only, plain text, or JSON served as text/html. linkedom's document.head and document.body getters then throw Cannot destructure property 'firstElementChild' from null or undefined value.
Every DOM rule that touches head or body throws on that page. runner.ts turns each throw into a <rule>-error check with status: "fail" at the rule's own severity. So one degenerate page produces a burst of bogus findings across categories, all naming that page: a11y/aria-hidden-body, perf/lcp-hints, perf/cls-hints, perf/inp-hints, perf/preconnect, perf/render-blocking, perf/font-loading, content/date-agreement, and more. Users see these as real errors, and they lower the score.
Seen in a 656-site batch on v0.0.140 (linux-x64, --offline --passive, 30 pages): 2 sites had this burst on one page each. The same URL fetched on its own returns normal HTML, so the bad body was transient (an empty or interstitial response during the crawl).
Repro, linkedom 0.18.13 as pinned:
import{parseHTML}from"linkedom";for(consthtmlof[""," ","<!-- c -->","plain text",'{"json":1}']){const{ document }=parseHTML(html);document.documentElement;// nulldocument.head;// throws}
parseDocument in packages/parser/src/index.ts returns linkedom's document unchanged.
Acceptance Criteria
parseDocument always returns a document with a non-null documentElement, head and body, for an empty string, whitespace, a comment only, plain text and JSON input. A parser test covers each case.
A crawled HTML page with an empty or non-HTML body is reported once, as a page-level finding or a not-evaluated reason (e.g. "empty or non-HTML response"), instead of one <rule>-error fail per DOM rule.
An engine-level test audits a fixture site with one empty-body page and asserts no Rule error: checks in the result.
Docs are updated if a new finding or not-evaluated reason is added.
Activity
fix(parser,rules): update tests and dom-size for the empty-shell pars…
fix(parser,rules): pages with no markup parse to an empty shell; id/f…
fix(parser,rules): update tests and dom-size for the empty-shell pars…
nc9 commentedon Oct 30, 2026
Fixed in v0.0.142 (73780351), via the stacked release PR #1331.