fix(is-offscreen): judge content in a fixed ancestor by its scroller #5568
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.44)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 94 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.272
No Reviewer Assigned
no_reviewer_assigned
0.120
Real PR Conversation Timeline
1 comments
"Review active on #5568"
general
weight: 0.35
cplieger
Summary
dom.isOffscreentreats an element as pinned to the viewport whenever it or any ancestor isposition: fixed(isFixedPosition(domNode)). A scroll container between the element and the fixed ancestor can still bring the element into view, butisOffscreencompares the element's current rect with the viewport and returns true once it lies below or right of it.isVisibleOnScreenthen returns false andcolor-contrastskips the text. On an app shell with a full-viewport fixed root (#app { position: fixed; inset: 0 }) only the first viewport of each scroller is checked.The fix adds a small helper,
isViewportAnchored, thatisOffscreencalls in place ofisFixedPosition. It walks from the element up to the nearestposition: fixedancestor and answers false as soon as it meets a scrollable ancestor (pergetScroll, so the fixed ancestor itself counts). Such an element takes the same path as any non-fixed element. An element that is fixed itself, or has no scroller between it and its fixed ancestor, behaves as before.isFixedPositionis not changed, so its other callers behave exactly as before.Two cases stay open, both closed by walking each containing block's scrollport as the issue suggests: inside a fixed root that does not scroll, a scroller whose own box lies past the viewport, and a positioned element whose containing block lies outside the scroller around it, now count as on screen. The
position: absoluteandnoParentScrolledbranches covered by #5069 are untouched.Tests
Three new cases in
test/commons/dom/is-offscreen.jsunderinside a position: fixed ancestor:Two controls pass before and after the change: an open shadow DOM element below the viewport with no scroller in between, and a fixed element below the viewport that scrolls itself. Both must stay offscreen.
Red, with the lib change reverted (
web-test-runner --config test/wtr.config.mjs --files test/commons/dom/is-offscreen.js, Chrome for Testing 158): 29 passed, 3 failed, eachAssertionError: expected true to be falsefor the three new cases above.Green, with the fix: 32 passed, 0 failed.
Also run on the fix:
pnpm test(tsc and all unit suites, 8941 passed, 0 failed),pnpm run test:integration(136 pages, 633 passes, 0 pages with failures), eslint and prettier on the changed files (clean). One earlier full run showed a single failure inobject-is-loaded-matches, a 250 ms load timeout that does not callisOffscreen; it passes alone and in the next full run.Closes: #5567