Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/cdk/scrolling/viewport-ruler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,17 @@ export class ViewportRuler implements OnDestroy {

const top =
-documentRect.top ||
document.body.scrollTop ||
// `document.body` can be `null` per WHATWG spec when document element is not `<html>`
// or has no body/frameset child: https://html.spec.whatwg.org/multipage/dom.html#dom-document-body
// Note: TypeScript incorrectly types this as non-nullable, but it can be `null` in practice.
document.body?.scrollTop ||
window.scrollY ||
documentElement.scrollTop ||
0;

const left =
-documentRect.left ||
document.body.scrollLeft ||
document.body?.scrollLeft ||
window.scrollX ||
documentElement.scrollLeft ||
0;
Expand Down
Loading