From accfaac26fccf6e7afcd02eae9207b2f34362982 Mon Sep 17 00:00:00 2001 From: henriklundgren Date: Mon, 28 Sep 2015 11:32:38 +0200 Subject: [PATCH] feature documentFragment see #37 --- index.js | 7 +++++++ test/index.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/index.js b/index.js index 902f796..711d1ea 100644 --- a/index.js +++ b/index.js @@ -32,6 +32,13 @@ function context () { if(l == null) ; + else if (isArray(l) && !e) { + // create document fragment + e = document.createDocumentFragment(); + forEach(l, function(child) { + e.appendChild(child); + }); + } else if('string' === typeof l) { if(!e) parseClass(l) diff --git a/test/index.js b/test/index.js index e091617..84b1f48 100644 --- a/test/index.js +++ b/test/index.js @@ -158,3 +158,12 @@ test('unicode selectors', function (t) { t.equal(h('span#⛄').outerHTML, '') t.end() }) + +test('create documentFragment', function(t) { + var tree = h([ + h('div.abc'), + h('div.def') + ]); + t.equal(tree.nodeName, '#document-fragment'); + t.end(); +})