diff --git a/lib/dom.js b/lib/dom.js index 1760293..2d62c62 100644 --- a/lib/dom.js +++ b/lib/dom.js @@ -21,6 +21,13 @@ function dom (tag, props, ...children) { } break; + case 'boolean': + if (!child) { + children.splice(i, 1) + break; + } + /* fallthrough */ + default: throw new Error(`Invalid child node: ${child}`) } diff --git a/test/unit/dom.test.js b/test/unit/dom.test.js index 8a1b52e..8f2bfbf 100644 --- a/test/unit/dom.test.js +++ b/test/unit/dom.test.js @@ -52,17 +52,13 @@ describe('etch.dom', () => { expect(component.element.outerHTML).to.equal('') }) - it('ignores nulls passed in the place of children, but throws an error if other invalid values are passed', () => { + it('ignores nulls and false passed in the place of children, but throws an error if other invalid values are passed', () => { const element = etch.render( -