Comparing version 1.1.0 to 1.2.0
31
index.js
@@ -6,3 +6,8 @@ var VAR = 0, TEXT = 1, OPEN = 2, CLOSE = 3, ATTR = 4 | ||
module.exports = function (h) { | ||
module.exports = function (h, opts) { | ||
if (!opts) opts = {} | ||
var concat = opts.concat || function (a, b) { | ||
return String(a) + String(b) | ||
} | ||
return function (strings) { | ||
@@ -46,5 +51,5 @@ var state = TEXT, reg = '' | ||
if (parts[i][0] === ATTR_KEY) { | ||
key += String(parts[i][1]) | ||
key = concat(key, parts[i][1]) | ||
} else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) { | ||
key += String(parts[i][2]) | ||
key = concat(key, parts[i][2]) | ||
} else break | ||
@@ -55,6 +60,6 @@ } | ||
if (!cur[1][key]) cur[1][key] = strfn(parts[i][1]) | ||
else cur[1][key] += String(parts[i][1]) | ||
else cur[1][key] = concat(cur[1][key], parts[i][1]) | ||
} else if (parts[i][0] === VAR && parts[i][1] === ATTR_VALUE) { | ||
if (!cur[1][key]) cur[1][key] = strfn(parts[i][2]) | ||
else cur[1][key] += String(parts[i][2]) | ||
else cur[1][key] = concat(cur[1][key], parts[i][2]) | ||
} else { | ||
@@ -77,3 +82,3 @@ i-- | ||
if (p[2] === undefined || p[2] === null) p[2] = '' | ||
else if (!p[2]) p[2] = String(p[2]) | ||
else if (!p[2]) p[2] = concat('', p[2]) | ||
if (Array.isArray(p[2][0])) { | ||
@@ -192,2 +197,9 @@ cur[2].push.apply(cur[2], p[2]) | ||
} | ||
function strfn (x) { | ||
if (typeof x === 'function') return x | ||
else if (typeof x === 'string') return x | ||
else if (x && typeof x === 'object') return x | ||
else return concat('', x) | ||
} | ||
} | ||
@@ -202,9 +214,2 @@ | ||
function strfn (x) { | ||
if (typeof x === 'function') return x | ||
else if (typeof x === 'string') return x | ||
else if (x && typeof x === 'object') return x | ||
else return String(x) | ||
} | ||
var closeRE = RegExp('^(' + [ | ||
@@ -211,0 +216,0 @@ 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', |
{ | ||
"name": "hyperx", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "tagged template string virtual dom builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24170
30
596
188
1