-
Notifications
You must be signed in to change notification settings - Fork 780
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
Why must text nodes be created explicitly? #1009
Comments
@hqproto Of course, not everyone prefers writing explicit hyperscript, but that's no problem! LIke you said it's a simple typeof check you can do in userland. You can make your own By the way: there is another issue with using hyperapp (and presumably superfine) with htm, and that is the fact that htm's caching conflicts with a performance optimization in hyperapp. Hyperapp expects you to give it new vnodes each time (because it mutates the ones you give it) which is not true with the default htm. You need to use the "mini" version of htm (which does not do any caching) to be safe. As an alternative for Hyperapp you could look in to hyperlit. (It probably works for superfine as well but it will import hyperapp so probably not what you want in that case) |
@hqproto if you would still like to use developit/htm (or JSX) for creating hyperapp views, I have published https://github.com/zaceno/hyperapp-jsx-pragma which exports a For use with htm, for example: import {app} from 'https://unpkg.com/hyperapp'
import htm from 'https://unpkg.com/htm/mini/index.module.js' //need the mini version because it doesn't cache nodes
import h from 'https://unpkg.com/hyperapp-jsx-pragma'
const html = htm.bind(h)
app({
init: {},
view: () => html`
<body>
<h1>Hello</h1>
</body>`,
node: document.body
}) But again, I recommend using Hyperlit for hyperapps, rather than developit/htm. The primary reason I published |
Text nodes are not strings. I'd also argue that using This change was also motivated by performance and size, since less code means fewer bytes and usually (but not always) faster execution. Whenever you use Simple is beautiful! 💗 |
Hi there,
Thank you for all your thoughtful work and sharing it with the world. I'm inspired by the discipline and thoughtfulness put into your projects like superfine and hyperapp.
Having used some other hyperscript implementations with various degrees of convenience, I wonder why text nodes must be created explicitly using superfine. Couldn't it be inferred with a simple typeof check?
One reason I ask is I'd like to use something like developit/htm to generate hyperscript from tagged template literals. While hyperscript has its benefits, I find it more convenient and natural to work with html using strings in some cases, e.g. integrating with a third-party design system.
Thanks for the handy library and your insight!
The text was updated successfully, but these errors were encountered: