yysun/apprun

Can I use other libraries in place of lit-html?

tvardy opened this issue ยท 7 comments

There are very cool competitors for lit-html - eg. HyperHtml, lighterhtml and uhtml by @WebReflection
Do you think I'd be able to use them with AppRun?

yysun commented
yysun commented

You need to let apprun use the render function from_uhtml_:

app.render = utml.render;

Here is an example:
https://apprun-uhtml.yysun.repl.co/

I new there needs to be a trick with the render... didn't think of such an easy one :D

Thanks!

yysun commented

Here is another example:
https://apprun-uhtml-custom-element.yysun.repl.co/

I like uhtml allows passing a function to the onclick attribute.

not sure it's relevant but uhtml and lighterhtml have render(where, what) instead of render(what, where):

render(document.body, html`
  <h1>Hello ๐Ÿ‘‹</h1>
`);

it makes it instantly visible where the layout will be placed, as opposite of needing to scroll down templates ๐Ÿ‘‹

yysun commented

@WebReflection, AppRun also uses render(where, what) so it is easy to replace the AppRun render engine with uhtml.

app.render = uhtml.render

When using lit-html, we need to switch the parameters.

app.render = (e, v) => litHtml.render(v, e);

Currently, AppRun uses morphdom for supporting HTML string in addition of JSX. I was thinking to replace morphdom with lit-html. I like uhtml more now.

uhtml uses udomdiff, in case it's needed ๐Ÿ‘