Skip to content

window.parent should be nullable #58464

New issue

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

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

Already on GitHub? Sign in to your account

Closed
yohabe opened this issue May 8, 2024 · 6 comments
Closed

window.parent should be nullable #58464

yohabe opened this issue May 8, 2024 · 6 comments
Labels
Not a Defect This behavior is one of several equally-correct options

Comments

@yohabe
Copy link

yohabe commented May 8, 2024

⚙ Compilation target

es2017

⚙ Library

ESNext

Missing / Incorrect Definition

In the whatwg definition, window.parent is nullable. whatwg/html#2123

The definition of window.parent in this repository is not nullable.

readonly parent: WindowProxy;

https://github.com/microsoft/TypeScript/blob/b9c71c3fc39f7cbafa82f8aa6f1d3b8a86e27ede/src/lib/dom.generated.d.ts#L26013-L26020

BTW, the definition of window.top is nullable, which is inconsistent.

 readonly top: WindowProxy | null;

https://github.com/microsoft/TypeScript/blob/b9c71c3fc39f7cbafa82f8aa6f1d3b8a86e27ede/src/lib/dom.generated.d.ts#L26069-L26070

Sample Code

readonly parent: WindowProxy;

Documentation Link

https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-window-object

@whzx5byb
Copy link

whzx5byb commented May 8, 2024

@yohabe
Copy link
Author

yohabe commented May 8, 2024

@whzx5byb
Thank you for your response.

Wouldn't it be better for consistency to make window.top non-nullable?

@RyanCavanaugh
Copy link
Member

Which one is this bug about?

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label May 8, 2024
@yohabe
Copy link
Author

yohabe commented May 9, 2024

There are three options.

Option 1: Comply with WHATWG by making window.parent nullable.

Option 2: Given that window.parent is non-nullable as TypeScript's specification, make window.top also non-nullable for consistency.

Option 3: Leave it as is, meaning window.parent is non-nullable and window.top is nullable. The inconsistency is attributed to TypeScript's specification.

@RyanCavanaugh RyanCavanaugh added Not a Defect This behavior is one of several equally-correct options and removed Needs More Info The issue still hasn't been fully clarified labels May 9, 2024
@RyanCavanaugh
Copy link
Member

Without a stronger argument for any one of those, we'll leave as-is. Thanks!

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
@yohabe
Copy link
Author

yohabe commented May 10, 2024

@RyanCavanaugh

What is the reason for creating a situation that contradicts the WHATWG specifications and lacks consistency with the definition of window.top?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Defect This behavior is one of several equally-correct options
Projects
None yet
Development

No branches or pull requests

3 participants