Skip to content

Commit

Permalink
supports null/undefined children
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Mar 5, 2017
1 parent c5df8e2 commit 21ab115
Show file tree
Hide file tree
Showing 2 changed files with 6 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
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ test('No modules', function (t) {
t.equal(renderToString(vnode), '<br>', 'void element')

vnode = h('div', [
undefined,
null,
h('p', 'Paragraph 1'),
h('p', [h('img')]),
h('ul', [
Expand Down

0 comments on commit 21ab115

Please sign in to comment.