Skip to content

Commit

Permalink
re-use existing DOM shim globals if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Feb 19, 2024
1 parent e9a5c34 commit a31aea6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/dom-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class CustomElementsRegistry {

// mock top level aliases (globalThis === window)
// https://developer.mozilla.org/en-US/docs/Web/API/Window
globalThis.addEventListener = noop;
globalThis.document = new Document();
globalThis.customElements = new CustomElementsRegistry();
globalThis.HTMLElement = HTMLElement;
// make this "idempotent" for now until a better idea comes along - https://github.com/ProjectEvergreen/wcc/discussions/145
globalThis.addEventListener = globalThis.addEventListener ?? noop;
globalThis.document = globalThis.document ?? new Document();
globalThis.customElements = globalThis.customElements ?? new CustomElementsRegistry();
globalThis.HTMLElement = globalThis.HTMLElement ?? HTMLElement;

0 comments on commit a31aea6

Please sign in to comment.