You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is pretty clunky, and it also doesn't support SSR (since the return value is a Node not an SSRTemplate). Perhaps better support for handling templates and child elements can be baked in?
A naive implementation would be to use DOMParser when a string is returned, and if the described node is an HTMLTemplateElement, then use .content.cloneNode(true) to handle slots properly. A similar approach could be used for when a Node is returned, and when an SSRTemplate's .create() method returns a Node.
Note that this might be the scope of helper libraries that allow creating templates. For example, right now rehtmdoes support templating and child elements quite nicely, but I feel it would be nice to add some more direct support as well (though the performance impact of this should also be analyzed).
The text was updated successfully, but these errors were encountered:
Right now, writing a component that handles templates and child elements works as follows:
This is pretty clunky, and it also doesn't support SSR (since the return value is a
Node
not anSSRTemplate
). Perhaps better support for handling templates and child elements can be baked in?A naive implementation would be to use
DOMParser
when a string is returned, and if the described node is anHTMLTemplateElement
, then use.content.cloneNode(true)
to handle slots properly. A similar approach could be used for when aNode
is returned, and when anSSRTemplate
's.create()
method returns aNode
.Note that this might be the scope of helper libraries that allow creating templates. For example, right now rehtm does support templating and child elements quite nicely, but I feel it would be nice to add some more direct support as well (though the performance impact of this should also be analyzed).
The text was updated successfully, but these errors were encountered: