fix(dev-server-hmr): fix compatibility with scoped-elements

This commit is contained in:
Alan Davalos
2021-01-18 18:49:01 +09:00
committed by Lars den Bakker
parent f82795726e
commit 4c6447a934

View File

@@ -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);
}