Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ module.exports = function (h, opts) {
)
}
} else if (s === VAR && p[1] === TEXT) {
if (p[2] === undefined || p[2] === null) p[2] = ''
else if (!p[2]) p[2] = concat('', p[2])
if (p[2] === undefined || p[2] === null || p[2] === false) p[2] = ''
else if (!p[2] || p[2] === true) p[2] = concat('', p[2])
if (Array.isArray(p[2][0])) {
cur[2].push.apply(cur[2], p[2])
} else {
Expand Down
22 changes: 20 additions & 2 deletions test/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ test('null value (empty)', function (t) {
t.end()
})

test('boolean value', function (t) {
test('string value (empty)', function (t) {
var tree = hx`<div>${''}</div>`
t.equal(vdom.create(tree).toString(), '<div></div>')
t.end()
})

test('boolean value (empty)', function (t) {
var tree = hx`<div>${false}</div>`
t.equal(vdom.create(tree).toString(), '<div>false</div>')
t.equal(vdom.create(tree).toString(), '<div></div>')
t.end()
})

test('boolean value', function (t) {
var tree = hx`<div>${true}</div>`
t.equal(vdom.create(tree).toString(), '<div>true</div>')
t.end()
})

Expand All @@ -26,3 +38,9 @@ test('numeric value', function (t) {
t.equal(vdom.create(tree).toString(), '<div>555</div>')
t.end()
})

test('numeric value (zero)', function (t) {
var tree = hx`<div>${0}</div>`
t.equal(vdom.create(tree).toString(), '<div>0</div>')
t.end()
})