microsoft / TypeScript-DOM-lib-generator

Tool for generating dom related TypeScript and JavaScript library files
Apache License 2.0
616 stars 417 forks source link

IntersectionObserverEntry: rootBounds property is never null #1694

Closed jayfz closed 7 months ago

jayfz commented 7 months ago

Hi!

The IntersectionObserverEntry interface in lib.dom.d.ts includes rootBounds definition as DOMRectReadOnly | null. However while reading MDN documentation and based on my own experimentation it seems this property is never null. It either represents the bounds of the root element or the viewport's.

MDN documentation link.

A DOMRectReadOnly which describes the root intersection rectangle. For roots which are the Document's viewport, this rectangle is the bounds rectangle of the entire document. Otherwise, it's the bounds of the root element.

Current behavior:

readonly rootBounds: DOMRectReadOnly | null;

Expected behavior

readonly rootBounds: DOMRectReadOnly;

Thank you.

RyanCavanaugh commented 7 months ago

The spec seems to describe when it's null:

rootBounds, of type DOMRectReadOnly, readonly, nullable For a same-origin-domain target, this will be the root intersection rectangle. Otherwise, this will be null.

jayfz commented 7 months ago

You are right! Thanks for pointing that out. That's a corner case I didn't consider.