Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Commit 19ec005

Browse files
committed
Adds the ability for child nodes to be an array of nodes.
Prior, something like: l.ul([l.li(null, 'First element'), liItems.map(item => l.li(null, item))]) would not be possible. The programmer's intent is clear, but lmth did not support it without needing to concat the first li element and the array of lis manually. Now, something like the above example works automatically. This is a major change.
1 parent beddc27 commit 19ec005

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

dist/lmth.min.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function Node(name, isVoid, id, class_, style, listeners, attributes, content, c
3030
this.listeners = listeners;
3131
this.attributes = attributes;
3232
this.content = content;
33-
this.children = children;
33+
// Merge child nodes with arrays of child nodes.
34+
this.children = children.reduce(function concatChild(children_, child) {
35+
return children_.concat(child);
36+
}, []);
3437

3538
return this;
3639
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lmth",
3-
"version": "6.3.0",
3+
"version": "7.0.0",
44
"description": "A \"type-safe\" HTML DSL for JavaScript environments.",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)