Skip to content

Commit

Permalink
Replace self with globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
mwszekely committed Feb 1, 2023
1 parent fd7330f commit cc56037
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/comlink.ts
Expand Up @@ -292,7 +292,7 @@ function isAllowedOrigin(

export function expose(
obj: any,
ep: Endpoint = self as any,
ep: Endpoint = globalThis as any,
allowedOrigins: (string | RegExp)[] = ["*"]
) {
ep.addEventListener("message", function callback(ev: MessageEvent) {
Expand Down Expand Up @@ -422,7 +422,7 @@ declare var FinalizationRegistry: FinalizationRegistry<Endpoint>;

const proxyCounter = new WeakMap<Endpoint, number>();
const proxyFinalizers =
"FinalizationRegistry" in self &&
"FinalizationRegistry" in globalThis &&
new FinalizationRegistry((ep: Endpoint) => {
const newCount = (proxyCounter.get(ep) || 0) - 1;
proxyCounter.set(ep, newCount);
Expand Down Expand Up @@ -550,7 +550,7 @@ export function proxy<T extends {}>(obj: T): T & ProxyMarked {

export function windowEndpoint(
w: PostMessageWithOrigin,
context: EventSource = self,
context: EventSource = globalThis,
targetOrigin = "*"
): Endpoint {
return {
Expand Down

0 comments on commit cc56037

Please sign in to comment.