From 4c6447a934390e2d5e6b68b64e530e60580dc249 Mon Sep 17 00:00:00 2001 From: Alan Davalos Date: Mon, 18 Jan 2021 18:49:01 +0900 Subject: [PATCH] fix(dev-server-hmr): fix compatibility with scoped-elements --- packages/dev-server-hmr/src/wcHmrRuntime.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/dev-server-hmr/src/wcHmrRuntime.js b/packages/dev-server-hmr/src/wcHmrRuntime.js index ca2a373c..4e6343b8 100644 --- a/packages/dev-server-hmr/src/wcHmrRuntime.js +++ b/packages/dev-server-hmr/src/wcHmrRuntime.js @@ -90,9 +90,12 @@ export class WebComponentHmr extends HTMLElement { constructor(...args) { super(...args); const key = keysForClasses.get(this.constructor); - const p = proxiesForKeys.get(key); - // replace the constructor with a proxy that references the latest implementation of this class - this.constructor = p.currentProxy; + // check if the constructor is registered + if (key) { + const p = proxiesForKeys.get(key); + // replace the constructor with a proxy that references the latest implementation of this class + this.constructor = p.currentProxy; + } // replace prototype chain with a proxy to the latest prototype implementation replacePrototypesWithProxies(this); }