← Back to Pull requests

fix(is-offscreen): judge content in a fixed ancestor by its scroller #5568

Open
cplieger opened this pull request with 94 lines diff across 2 files
View on GitHub
cplieger cplieger commented on Nov 16, 2026 22:39 UTC
Author

Summary

dom.isOffscreen treats an element as pinned to the viewport whenever it or any ancestor is position: fixed (isFixedPosition(domNode)). A scroll container between the element and the fixed ancestor can still bring the element into view, but isOffscreen compares the element's current rect with the viewport and returns true once it lies below or right of it. isVisibleOnScreen then returns false and color-contrast skips 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, that isOffscreen calls in place of isFixedPosition. It walks from the element up to the nearest position: fixed ancestor and answers false as soon as it meets a scrollable ancestor (per getScroll, 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.

isFixedPosition is 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: absolute and noParentScrolled branches covered by #5069 are untouched.

Tests

Three new cases in test/commons/dom/is-offscreen.js under inside a position: fixed ancestor:

  • below the scrollport of a vertical scroller

  • right of the scrollport of a horizontal scroller

  • below the scrollport when the fixed ancestor scrolls itself
  • 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, each AssertionError: expected true to be false for 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 in object-is-loaded-matches, a 250 ms load timeout that does not call isOffscreen; it passes alone and in the next full run.

    Closes: #5567

    Diff: 94 lines (+91 / -3) across 2 files Reviewer: None requested Review duration: 24158m
    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
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    None requested
    Assignees
    cplieger cplieger
    Labels
    risk: low confidence: 44.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.7% (MEDIUM) · Higher = larger blast radius
    43.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.2% · Lower = rushed or shallow review
    44.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.4% · Safe to merge
    24.4%