canjs / can-stache-element

Create custom elements with can-stache and can-define-class
https://canjs.com/doc/can-stache-element.html
MIT License
3 stars 1 forks source link

Finalize how to render to shadowDOM #38

Open phillipskevin opened 5 years ago

phillipskevin commented 5 years ago

You currently can render into shadowDOM by setting the viewRoot property:

https://github.com/canjs/can-stache-define-element/blob/75be0f9c937459f6eba13bcf21a09ec7999c26e4/src/mixin-stache-view-test.js#L44

This isn't currently documented because we might want to change how this works. It might be easier to just automatically render into shadowDOM if attachShadow was called and not have a special viewRoot property. Although maybe there will be use-cases for rendering somewhere else, so viewRoot might be useful.

matthewp commented 5 years ago

I think viewRoot is a bit more flexible than checking for a .shadowRoot property. It's explicit and will work with closed shadow roots as well. If a shadow exists then there's probably no point of rendering a template into the light DOM. At least I've never heard of anyone doing that. Keeping viewRoot gives you flexibility here. You could render a template into the shadow (manually) and have the framework render it into the element light DOM. Weird but possible.

justinbmeyer commented 5 years ago

the portal helper is semi-similar ... not sure if this means anything from an API perspective