Skip to content

Commit

Permalink
chore: add polyfill for CustomEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Oct 10, 2024
1 parent a50fcac commit 61c2c52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/sdk/src/create/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import "../custom-event-polyfill.js";
export { createLightNode } from "./create.js";
export { defaultLibp2p, createLibp2pAndUpdateOptions } from "./libp2p.js";
12 changes: 12 additions & 0 deletions packages/sdk/src/custom-event-polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (typeof CustomEvent === "undefined") {
class CustomEvent<T = unknown> extends Event {
public detail: T;

public constructor(type: string, eventInitDict?: CustomEventInit<T>) {
super(type, eventInitDict);
this.detail = eventInitDict?.detail as T;
}
}

(globalThis as Record<string, unknown>).CustomEvent = CustomEvent;
}

0 comments on commit 61c2c52

Please sign in to comment.