Comparing version 1.2.0 to 1.3.0
11
index.js
@@ -48,2 +48,3 @@ var VAR = 0, TEXT = 1, OPEN = 2, CLOSE = 3, ATTR = 4 | ||
var key = '' | ||
var copyKey | ||
for (; i < parts.length; i++) { | ||
@@ -53,3 +54,11 @@ if (parts[i][0] === ATTR_KEY) { | ||
} else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) { | ||
key = concat(key, parts[i][2]) | ||
if (typeof parts[i][2] === 'object' && !key) { | ||
for(copyKey in parts[i][2]) { | ||
if (parts[i][2].hasOwnProperty(copyKey) && !cur[1][copyKey]) { | ||
cur[1][copyKey] = parts[i][2][copyKey] | ||
} | ||
} | ||
} else { | ||
key = concat(key, parts[i][2]) | ||
} | ||
} else break | ||
@@ -56,0 +65,0 @@ } |
{ | ||
"name": "hyperx", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "tagged template string virtual dom builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,1 +37,22 @@ var test = require('tape') | ||
}) | ||
test('multiple keys', function (t) { | ||
var props = { | ||
type: 'text', | ||
'data-special': 'true' | ||
} | ||
var key = 'data-' | ||
var value = 'bar' | ||
var tree = hx`<input ${props} ${key}foo=${value}>` | ||
t.equal(vdom.create(tree).toString(), '<input type="text" data-special="true" data-foo="bar" />') | ||
t.end() | ||
}) | ||
test('multiple keys dont overwrite existing ones', function (t) { | ||
var props = { | ||
type: 'text' | ||
} | ||
var tree = hx`<input type="date" ${props}>` | ||
t.equal(vdom.create(tree).toString(), '<input type="date" />') | ||
t.end() | ||
}) |
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
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
25385
31
635