You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe with something like this you could get rid of the Object.setPrototypeOf() and still have the right constructor be executed on instanciations:
varparent=HTMLElement;varRootElement=function(){console.log("Executing RootElement ctor.");returnReflect.construct(HTMLElement.constructor,[],RootElement);};// Used to make the new class extends its parent:varprotoChainingProxy=function(){};// This function can actually be reused or cached, it doesn't have to be re-created each time.// Prepare prototype chaining to the parent:protoChainingProxy.prototype=parent.prototype;// Make the prototype's chain from RootElement to it's parent:varproto=RootElement.prototype=newprotoChainingProxy;proto.constructor=RootElement;// This is not required, but is good conduct and might be expected from other libsconsole.log(RootElement);console.log(newRootElement());console.log(newRootElement()instanceofHTMLElement);// true
core/src/registerRoot.js
Lines 28 to 29 in 12250ef
Hi, I read the article Writing a JavaScript Framework - The Benefits of Custom Elements. And I have been thinking about the use of
Object.setPrototypeOf()
which is a performance killer.Why could you not use
Object.create()
? What would be missing if you usedObject.create()
?The text was updated successfully, but these errors were encountered: