Skip to content
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

fix(cli/rt/main): Add global interface objects #7875

Merged
merged 2 commits into from
Oct 11, 2020

Conversation

nayeemrmn
Copy link
Collaborator

@nayeemrmn nayeemrmn commented Oct 7, 2020

  • Window
  • DedicatedWorkerGlobalScope
  • WorkerGlobalScope

Matches browsers.

Window globalThis prototype chain: Window -> EventTarget -> Object.
Worker globalThis prototype chain: DedicatedWorkerGlobalScope -> WorkerGlobalScope -> EventTarget -> Object.

console.log(globalThis);

// Before:
// { ... }

// After:
// Window { ... }

Use the following to detect a web worker environment:

if (globalThis.WorkerGlobalScope && globalThis instanceof WorkerGlobalScope) {
  // ...
}

@nayeemrmn nayeemrmn changed the title fix(cli/rt/main): Add Window and WorkerGlobalScope to globalThis prototypes fix(cli/rt/main): Add global object interfaces Oct 8, 2020
@nayeemrmn nayeemrmn changed the title fix(cli/rt/main): Add global object interfaces fix(cli/rt/main): Add global interface objects Oct 8, 2020
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

LGTM

I hate weak inequality operator, and thought we had a linting rule to enforce it, but it seems we have a mixture of weak and strong equality/inequality in the code base so, 🤷‍♂️.

cli/rt/99_main.js Outdated Show resolved Hide resolved
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

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

LGTM

@kitsonk kitsonk merged commit 5f3028a into denoland:master Oct 11, 2020
@nayeemrmn nayeemrmn deleted the global-classes branch October 11, 2020 22:06
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.

None yet

3 participants