developit / htm

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zero is translated as empty string when htm is bound to vhtml

aral opened this issue · comments

htm bound to vhtml translates a numeric zero value as an empty string.

To reproduce

import htm from 'htm'
import vhtml from 'vhtml'

const html = htm.bind(vhtml)

let count = 0
console.info(html`<h1>The count is →${count}</h1>`)

count++
console.info(html`<h1>The count is →${count}</h1>`)

Expected result

<h1>The count is →0←</h1>
<h1>The count is →1←</h1>

Actual result

<h1>The count is →←</h1>
<h1>The count is →1←</h1>

The (yucky) workaround

html`<h1>The count is →${count.toString()}</h1>`

(I’m not sure if its htm or vhtml to blame here as I haven’t had a chance to dig into it; just strumbled on this while trying to reproduce a different issue.)

This seems to be a problem with vhtml, not htm.

PR: developit/vhtml@master...aral:vhtml:patch-1