Open frank-dspeed opened 4 years ago
I’m not sure if I’m following but are you suggesting there that we’d give an instance of Element and some author-scripted defined class which subclasses it, and “upgrade” the instance to be an instance of the latter? And am I understanding right that the primary benefit here is to get lifecycle callback since you already have an instance?
@rniwa your right i want to upgrade a existing element with all expected behavior of a
customElement.defined('elemen-name', class extends HTMLElement /* also support build in but that is probally covered as its already constructed*/)
out of myView thats it but full inernals may have more behavior to much to list here
I Think i realy could use
Object.assign(document.createElement(''), classOrObject)
I think the only complicated part is the attribute observation but maybe there is more
If all that is not possible i think i could even use a customElementV1 polyfill implamentation to have my OwnCustom Element Implamentation but thats maybe not worth it.
i found out we need the following:
to have a easy implamentation of this we would need
document.createElement('p',class extends ParagraphHTMLElement {})
document.createElement('my-element',class extends HTMLElement {})
note that we don't need to supply extends since we don't hornor the is attribute when we create the element our self its not the ui thats upgrading the element .
// el === document.createElement('p')
customElements.upgrade(el,class extends ParagraphHTMLElement {})
I don't understand why we can't offer the simple customElement.define(el,class) interface directly and let that return The upgraded Element
We could then simply have array collections listening on dom insertion and upgrade via that or we can manual upgrade importent is to open the API to create a element via customElement.define so that the final class gets returned