WebReflection / hyperHTML

A Fast & Light Virtual DOM Alternative
ISC License
3.07k stars 112 forks source link

HTML rendered as raw text? #5

Closed n1k0 closed 7 years ago

n1k0 commented 7 years ago

I'm toying around with the lib and stumbled upon a case where a HTML string is rendered as plain text instead of HTML: https://jsfiddle.net/n1k0/7odja84y/1/

That may just be me misreading docs but this behavior is rather surprising :)

WebReflection commented 7 years ago

You didn't read the little doc 😉

function app(render) {
  const state = {
    title: "Hello",
    time: new Date().toLocaleTimeString(),
  };
  render`
    <div>${
      title(render, state) +
      time(render, state)
    }</div>
  `;
}

It's very simple: text can in the wild.

It's the third point in the F.A.Q.s

and explained in depth in the deep dive: https://github.com/WebReflection/hyperHTML/blob/master/DEEPDIVE.md#how-are-text-nodes-updated

There's no other way otherwise to differentiate between text and html or fragments so .... KISS 😉