Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Inconsistent types between Document scrollingElement and documentElement #60838

Open
aayla-secura opened this issue Dec 22, 2024 · 0 comments
Open
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@aayla-secura
Copy link

🔎 Search Terms

I think document.scrollingElement should be of type Document["documentElement"] | null instead of Element | null. The spec (e.g. this and this) says that in standards mode scrollingElement returns the document root, which is document.documentElement and in quirks mode returns document.body or null.

document.body is always HTMLElement (right?) In principle, document.documentElement does not have to be HTMLElement (and there's an open issue about this, #29052, but currently Document.documentElement is still defined as HTMLElement, for some reason. So how come document.scrollingElement is not HTMLElement | null?

🕗 Version & Regression Information

N/A

⏯ Playground Link

No response

💻 Code

// Your code here

🙁 Actual behavior

document.scrollingElement is of type Element | null whereas document.documentElement and document.body are both of type HTMLElement.

🙂 Expected behavior

The non-null part of document.scrollingElement should be the same type as document.documentElement, which technically should be Element, but if document.documentElement is left as HTMLElement, as is currently, then document.scrollingElement should also be this.

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Jan 3, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 3, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants