Skip to content

Commit

Permalink
Merge branch 'bouzuya-support-null-undefined'
Browse files Browse the repository at this point in the history
  • Loading branch information
acstll committed Sep 19, 2017
2 parents c041b5e + 39489d2 commit e93d88d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module.exports = function init (modules) {
}

return function renderToString (vnode) {
if (typeof vnode === 'undefined' || vnode === null) {
return ''
}

if (!vnode.sel && vnode.text) {
return vnode.text
}
Expand Down
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ test('No modules', function (t) {
])
t.equal(renderToString(vnode), '<div><p>Paragraph 1</p><p><img></p><ul><li>1</li><li>2</li><li>3</li></ul></div>', 'nesting')

vnode = h('div', [
undefined,
null
])
t.equal(renderToString(vnode), '<div></div>', 'null / undefined')

vnode = h('!', 'comment text')
t.equal(renderToString(vnode), '<!--comment text-->', 'comment')

Expand Down

0 comments on commit e93d88d

Please sign in to comment.