Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloneNode and Custom Elements #9

Open
trusktr opened this issue Feb 25, 2019 · 6 comments
Open

cloneNode and Custom Elements #9

trusktr opened this issue Feb 25, 2019 · 6 comments

Comments

@trusktr
Copy link

trusktr commented Feb 25, 2019

My fear is that using Custom Elements in domc (which uses cloneNode) will result in errors/bugs due to certain things like JS props not being cloned to the new nodes. Thoughts on this?

@trusktr
Copy link
Author

trusktr commented Feb 25, 2019

Maybe you can add thoughts to this old thread, if you have any: WICG/webcomponents#176

@ryansolid
Copy link

ryansolid commented Feb 25, 2019

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.

@Freak613
Copy link
Owner

Freak613 commented Mar 4, 2019

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)

@ryansolid
Copy link

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.

@Freak613
Copy link
Owner

Freak613 commented Apr 16, 2019

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.

@frank-dspeed
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants