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

Commit

Permalink
Adds the ability for child nodes to be an array of nodes.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisdotcode committed Mar 22, 2016
1 parent beddc27 commit 19ec005
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
28 changes: 14 additions & 14 deletions dist/lmth.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function Node(name, isVoid, id, class_, style, listeners, attributes, content, c
this.listeners = listeners;
this.attributes = attributes;
this.content = content;
this.children = children;
// Merge child nodes with arrays of child nodes.
this.children = children.reduce(function concatChild(children_, child) {
return children_.concat(child);
}, []);

return this;
}
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": "lmth",
"version": "6.3.0",
"version": "7.0.0",
"description": "A \"type-safe\" HTML DSL for JavaScript environments.",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 19ec005

Please sign in to comment.