Open trusktr opened 5 years ago
Maybe you can add thoughts to this old thread, if you have any: https://github.com/w3c/webcomponents/issues/176
I'm pretty sure cloneNode only happens on initial instantiation of template instances. So when a template is drawn the first time or an new row is added to list. Given the use of a string templating I'm not sure where JS props would come into the picture. The node is cloned then binding is applied to the clone, and then that clone attached to the DOM. Basically the template being cloned from is abstracted from you , and you'd only ever interface with the clone and it is never cloned again. I'm yet to hit an issue using Custom Elements this way using this cloneNode method as used in DomC.
Mind you the Custom Elements I use do most of their work in the Connected Callback instead of the constructor (historically reasons to support backward compatible polyfills in ES5). Have you seen an example of this being a problem? I'm actually pretty interested as I use this exact same approach in my libraries.
As of now, Domc hasn't been tested with Custom Elements, nor designed with it in mind. I had to think about its support. Sorry for the late response)
I should add that lit-html and lighterhtml also use this approach of setting templates and cloning them. Both libraries known to support custom elements. So unless you have found a specific issue I do not imagine there should be any issue with the approach taken here. Not to say Domc might not have other hangups with web components, just that the cloneNode part is fairly ubiquitous.
I just can't state that they are supported or tested, until test them myself. But I don't stop other minds to try and see.
Upd: I'm not saying I'm not going to test it, just don't have time for that right now. I hope will have it in nearest future.
i have created tag-html as succesor of lit-html with webcomponents in mind i will adapt domc as additional algo as my framework supports dirrent algos to be modular and flexible i can expect how to handle all that with domc support as my tag-html famework is also string template based but it uses tagged template literals.
it replaces lit-html directives with customElements support
My fear is that using Custom Elements in
domc
(which usescloneNode
) will result in errors/bugs due to certain things like JS props not being cloned to the new nodes. Thoughts on this?