diff --git a/index.js b/index.js index d054910..28e8389 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,7 @@ export function toString(node, separator = '') { if (typeof node.value === 'string') return node.value // @ts-ignore Looks like a list of nodes or parent. - children = 'length' in node ? node : node.children + children = ('length' in node ? node : node.children) || [] // Shortcut: This is pretty common, and a small performance win. if (children.length === 1 && 'value' in children[0]) { diff --git a/test.js b/test.js index 943641a..a4f11ab 100644 --- a/test.js +++ b/test.js @@ -50,5 +50,7 @@ test('toString()', function (t) { 'should support separators' ) + t.equal(toString(u('foo')), '', 'should support voids') + t.end() })