Skip to content

Commit

Permalink
+ perfs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lcfvs committed Jul 1, 2021
1 parent da2e6b2 commit 507c545
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const tokenize = node => {
for (const { name, value } of current.attributes) {
const tokens = identify(value)

if (tokens) {
if (tokens.length) {
attributes.set(name, tokens)
}
}
Expand Down Expand Up @@ -141,9 +141,15 @@ const fill = template => {
}

const value = (tokens, node, name, template) => {
const { length } = tokens

if (!length) {
return
}

let value = node.getAttribute(name)

if (tokens.length === 1) {
if (length === 1) {
const [{ key, optional }] = tokens

value = resolve(key, optional, template)
Expand Down Expand Up @@ -179,7 +185,7 @@ const content = (tokens, node, template) => {
const value = resolve(key, optional, template)
const replacements = Array.isArray(value)
? value
: value && value[Symbol.iterator]
: value && typeof value === 'object' && value[Symbol.iterator]
? [...new Map(value).values()]
: [value]

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": "4.0.0",
"version": "4.0.1",
"description": "A composable DOM based template engine",
"type": "module",
"scripts": {
Expand Down

0 comments on commit 507c545

Please sign in to comment.