Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
subnested arrays concat
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxenko committed Dec 22, 2016
1 parent 9bd5fae commit be8bf7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/h.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var h = function(argv) {
} else if (Array.isArray(argv[2])) {
this.children = argv[2];
} else {
this.children = [].slice.call(argv, 2, argv.length)
this.children = [].concat.apply([], [].slice.call(argv, 2, argv.length))
.filter(function(n) {
return n !== null && n !== undefined;
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "basic-virtual-dom",
"version": "0.1.5",
"version": "0.1.6",
"description": "Basic virtual dom implementation",
"main": "index.js",
"files": [
Expand Down
11 changes: 11 additions & 0 deletions tests/mocha-tests/h.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,15 @@ describe('Test h()', function() {
var checkbox = p.childNodes[0];
expect(checkbox.checked).to.be.true;
});

it('should create from arrays of childs', function() {
var p = h('div', null ,
h('span', null,'child1'),
'child2',
h('span', null, 'child3'),
[ h('div', null, '1'), h('div', null, '2') ]
);

expect(p.children[3].tag).to.be.equal('div');
});
});

0 comments on commit be8bf7a

Please sign in to comment.