V1 as an Object (without class)
noopole opened this issue · 1 comments
noopole commented
You wrote about v1:
As with the v0 API, the ElementClass can be [...] an object with a prototype that extends the base class's.
Do you know how to define shuch a custom element (without the class
notation) ?
I've tried but Chrome raise an error and wants a functionas the second parameter. Exemple:
customElements.define( "object-v1", { prototype: Object.create( HTMLElement.prototype ) } )
noopole commented
I've found a way after all:
var CEo = function ()
{
console.log( "created" )
return Reflect.construct( HTMLElement, [], CEo )
}
CEo.prototype = Object.create( HTMLElement.prototype )
CEo.prototype.connectedCallback = function ()
{
console.log( "connected" )
this.innerHTML = "Hello v1"
}
customElements.define( "object-v1", CEo )