Title: window.parent should have the same global variables as window · Issue #41684 · microsoft/TypeScript · GitHub
Open Graph Title: window.parent should have the same global variables as window · Issue #41684 · microsoft/TypeScript
X Title: window.parent should have the same global variables as window · Issue #41684 · microsoft/TypeScript
Description: TypeScript Version: 4.1.2 Search Terms: window.parent, window.Element, globalThis Code window.HTMLDivElement; window.parent.HTMLDivElement; // Error here Expected behavior: The window.parent object should have the same base global variab...
Open Graph Description: TypeScript Version: 4.1.2 Search Terms: window.parent, window.Element, globalThis Code window.HTMLDivElement; window.parent.HTMLDivElement; // Error here Expected behavior: The window.parent object...
X Description: TypeScript Version: 4.1.2 Search Terms: window.parent, window.Element, globalThis Code window.HTMLDivElement; window.parent.HTMLDivElement; // Error here Expected behavior: The window.parent object...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/41684
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"window.parent should have the same global variables as window","articleBody":"**TypeScript Version:** 4.1.2\r\n\r\n**Search Terms:** `window.parent`, `window.Element`, `globalThis`\r\n\r\n**Code**\r\n\r\n```ts\r\nwindow.HTMLDivElement;\r\nwindow.parent.HTMLDivElement; // Error here\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nThe `window.parent` object should have the same base global variables as the `window` object. If not in the context of iframe, then `window === window.parent` so all global variables should be the same in such a case. When being in the iframe context `window !== window.parent` however it should still have all the base global variables, so that we can do for example `element instanceof window.parent.Element`. You could think, why don't just write `element instanceof Element`? The answer is that it would work in almost all browsers beside Chrome. And Chrome is actually the one implementing it correctly. Both global window and iframe window have their own global context so `window.parent.Element !== window.Element`. In TS all the global variables are defined in the `globalThis` so the type for the `window.parent` should be `declare var parent: Window & typeof globalThis;`\r\n\r\n**Actual behavior:**\r\n\r\nThe `window.parent.HTMLDivElement;` does not exist on type Window.\r\n\r\n**Playground Link:** https://www.typescriptlang.org/play?#code/O4SwdgJg9sB0ASAVAsgGQCIgG4FEA2ApgLYFgAuA3AFCiQywAOAhgE6lkIobb7HsVA\r\n","author":{"url":"https://github.com/lukejagodzinski","@type":"Person","name":"lukejagodzinski"},"datePublished":"2020-11-25T03:29:31Z","url":"https://github.com/microsoft/TypeScript/issues/41684"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:610acf57-dcba-a039-6283-9b0ebf0614ee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D992:4279A:26A7B3C:3405692:6B01BD39 |
| html-safe-nonce | 91c4caf4cdb0cc2fe9c0d5a36d301130388f061aa65934a63a2e7fd8a97636ae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTkyOjQyNzlBOjI2QTdCM0M6MzQwNTY5Mjo2QjAxQkQzOSIsInZpc2l0b3JfaWQiOiIzMDE0ODk5ODM2MjE1NDc1NTEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e18901be306851ac08e2076084133dcbadcef7998a29ffca7a23184d4da5666e |
| hovercard-subject-tag | issue:750354273 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/41684/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d3b07304007b10d9af9353fba80238ab29f0adbbe904ebadfbd6f509c8642da/microsoft/TypeScript/issues/41684 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d3b07304007b10d9af9353fba80238ab29f0adbbe904ebadfbd6f509c8642da/microsoft/TypeScript/issues/41684 |
| og:image:alt | TypeScript Version: 4.1.2 Search Terms: window.parent, window.Element, globalThis Code window.HTMLDivElement; window.parent.HTMLDivElement; // Error here Expected behavior: The window.parent object... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lukejagodzinski |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width