Repository navigation
fix(rules): perf/dom-size measures total nodes and depth from body #548 - #886
Merged
Merged
Conversation
All three checks now walk <body>, as dom-max-children did and Lighthouse's DOMStats does: total = body descendants, body = depth 1. Thresholds unchanged. Rootless documents stay a skipped check. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/548-dom-size-body-scope
branch
from
October 17, 2026 01:14
0456cb5 to
f61d4db
Compare
nc9
marked this pull request as ready for review
October 17, 2026 01:14
|
Reviewed the diff. The change does what the description says: total nodes and depth are now measured from
Nothing blocking. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #548
The decision is recorded on the issue before the change (#548 (comment)): body-only, for all three checks.
What changed
perf/dom-sizemeasures total nodes and depth from<body>, asdom-max-childrenhas since perf/dom-size: dom-max-children counts the children of <head> #483 and as Lighthouse's DOM size audit does. Lighthouse's DOMStats gatherer walksdocument.body, counts the body's descendants (totalBodyElements) and puts the body at depth 1. This rule now does the same: the total excludes<body>itself, and<body>is level 1.<head>metadata (hreflang alternates, preload hints, meta tags) no longer adds to the count or the depth.<body>gets one skippeddom-total-nodescheck (No body element found). A rootless document (empty, text-only or comment-only HTML, where linkedom'sbodygetter throws) keepsNo document root found.apps/cli/src/benchmark/mapping.tspairs LHdom-sizewithperf/dom-sizeby id. That still holds, and the two now measure the same scope.Acceptance criteria
<body>; a large head with a small body reports the body numbersTests
packages/rules/tests/dom-size.test.ts10/10, including rootless real-parse cases. Golden suite: 209/210. The one failure is the same 180 s timeout inrule-cache-replay-golden("a page where a rule timed out is not stored") that showed up in full-suite runs on two other branches; that file passes alone (11/11, 15 s). No pinned number moved. Typecheck (rules), oxlint on changed files,tangly check --strict, codex review (2 rounds; the P2 rootless-document guard is fixed).