From b6a478f37648491321077750bfca7bddf3cafadd Mon Sep 17 00:00:00 2001 From: Sebastiaan Date: Fri, 28 Oct 2022 18:34:30 +0200 Subject: [PATCH] Fix/node custom elements (#5235) * adapter-node fix CustomElementRegistry * Add changeset * Add fallback CustomElementRegistry --- .changeset/silly-mirrors-give.md | 5 +++++ packages/webapi/src/lib/CustomElementRegistry.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/silly-mirrors-give.md diff --git a/.changeset/silly-mirrors-give.md b/.changeset/silly-mirrors-give.md new file mode 100644 index 000000000000..baa94162f934 --- /dev/null +++ b/.changeset/silly-mirrors-give.md @@ -0,0 +1,5 @@ +--- +'@astrojs/webapi': patch +--- + +Fix CustomElementRegistry for Node SSR Adapter diff --git a/packages/webapi/src/lib/CustomElementRegistry.ts b/packages/webapi/src/lib/CustomElementRegistry.ts index 3429e1e7308b..21f775d5e527 100644 --- a/packages/webapi/src/lib/CustomElementRegistry.ts +++ b/packages/webapi/src/lib/CustomElementRegistry.ts @@ -81,8 +81,9 @@ export const initCustomElementRegistry = ( const CustomElementRegistry = target.CustomElementRegistry || globalThis.CustomElementRegistry - const customElements: CustomElementRegistry = (target.customElements = - Object.create(CustomElementRegistry.prototype)) + const customElements: CustomElementRegistry = + target.customElements || + (target.customElements = new CustomElementRegistry()) _.INTERNALS.set(customElements, { constructorByName: new Map(),