diff --git a/src/index.js b/src/index.js index 8d4b817..6e1cc9e 100644 --- a/src/index.js +++ b/src/index.js @@ -35,7 +35,7 @@ export class EL { this.content = new TEXT(this.content); } - if (!Array.isArray(this.content)) { + if (null != content && !Array.isArray(this.content)) { this.content = [this.content]; } diff --git a/tests/charata.test.js b/tests/charata.test.js index 95cb391..97d7b63 100644 --- a/tests/charata.test.js +++ b/tests/charata.test.js @@ -41,4 +41,13 @@ describe('charata', () => { assert.ok(myUl.length === 1); assert.ok(myLIs.length === 3); }); + + it('should render elements with no children nor text', () => { + el('div', null).renderTo(document.body); + + let myDiv = document.getElementsByTagName('div'); + + assert.strictEqual(myDiv.length, 1); + assert.strictEqual(myDiv[0].innerHTML, ''); + }); });