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

Support for web components #12

Open
lastmjs opened this issue Nov 21, 2017 · 6 comments
Open

Support for web components #12

lastmjs opened this issue Nov 21, 2017 · 6 comments

Comments

@lastmjs
Copy link

lastmjs commented Nov 21, 2017

This is potentially an idea for improvement. Is there support for the web components standards: template, custom elements, shadow DOM?

@mbasso
Copy link
Owner

mbasso commented Nov 21, 2017

Hi @lastmjs,
it's a nice idea. At the moment I need some time to learn more about this topic, I haven't in mind if it can be added directly to the core of asm-dom without a new module. I'll look into it as soon as possible!

@SatoshiKawabata
Copy link

SatoshiKawabata commented Dec 13, 2017

I'm looking forward to support Web Components!
I tried Web Components but it was not working...
https://github.com/SatoshiKawabata/asm-dom-example

@mbasso
Copy link
Owner

mbasso commented Dec 13, 2017

Hi @SatoshiKawabata,
I've just checked out your example and I've found a problem with the patch function, in particular, you need to init asm-dom with the option unsafePatch = true.
In this way you can call patch in 2 different places (inside and outside the web-component).
You can read more about that here, this is basically a guard that prevents strange behaviours if you try to provide wrong params to patch.
I've also found your asm-dom-vs-virtual-dom repository (that's awesome 😄 ) and there all works fine, so don't worry about this option.

If you try to modify your code as follow you can see that your web component works as expected:

init({
  unsafePatch: true,
}).then(asmDom => {
  // ...
});

If you are interested in experimenting with asm-dom and webcomponents please let me know, it might be a good starting point to write some tests

@SatoshiKawabata
Copy link

@mbasso Great! It's working! Thanks.

@mbasso
Copy link
Owner

mbasso commented Dec 14, 2017

@SatoshiKawabata you're welcome!

@lastmjs are you thinking about something like this for web components? (it can be done in the same way using C++ APIs)
Or you would like to have a different API?

@stereobooster
Copy link

There is also https://github.com/skatejs/ssr, which uses undom to generate WebComponents at the server side. It can be useful reference

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

No branches or pull requests

4 participants