From d689d3202a72a5c125f77f684520ede6547cdbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Scoubeau?= Date: Fri, 15 Jan 2016 20:02:51 +0100 Subject: [PATCH 1/2] Add failing test case. --- tests/charata.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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, ''); + }); }); From f1a1fe7df2f1411539dd280cf0693871c3453507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Scoubeau?= Date: Fri, 15 Jan 2016 20:04:07 +0100 Subject: [PATCH 2/2] Do not wrap node content in array in case it's null. --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; }