Skip to content

getElementById and getSelection could return null#221

Merged
nojaf merged 2 commits intorescript-lang:mainfrom
Freddy03h:dom-api-null
Mar 18, 2026
Merged

getElementById and getSelection could return null#221
nojaf merged 2 commits intorescript-lang:mainfrom
Freddy03h:dom-api-null

Conversation

@Freddy03h
Copy link
Contributor

Document getElementById

An Element object describing the DOM element object matching the specified ID, or null if no matching element was found in the document

DocumentFragment getElementById

An Element object describing the DOM element object matching the specified ID, or null if no matching element was found in the document fragment.


Window getSelection

A Selection object, or null if the associated document has no browsing context (for example, the window is an <iframe> that is not attached to a document).

When called on an <iframe> that is not displayed (e.g., where display: none is set) Firefox returns null, whereas other browsers returns a Selection object with Selection.type set to None.

Document getSelection

A Selection object, or null if the document has no browsing context (for example, it is the document of an <iframe> that is not attached to a document).

Copy link
Member

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nojaf nojaf merged commit 3cb774d into rescript-lang:main Mar 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants