Skip to content

Commit

Permalink
Distinct array & other iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
Lcfvs committed May 31, 2021
1 parent 20a97bb commit 1448f42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ function content (template, node) {
} else if (typeof value === 'object') {
const { ownerDocument } = node
const container = ownerDocument.createDocumentFragment()
const nodes = value[Symbol.iterator] ? [...new Map(value).values()] : [value]
const nodes = Array.isArray(value)
? value
: value[Symbol.iterator]
? [...new Map(value).values()]
: [value]

nodes.forEach(child => container.appendChild(render(child)))
node.parentNode.replaceChild(container, node)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lcf.vs/dom-engine",
"version": "2.3.5",
"version": "2.3.6",
"description": "A composable DOM based template engine",
"type": "module",
"main": "lib/engine.js",
Expand Down

0 comments on commit 1448f42

Please sign in to comment.