Comparing version 2.0.1 to 2.0.2
13
index.js
@@ -81,3 +81,4 @@ var attrToProp = require('hyperscript-attribute-to-property') | ||
} else { | ||
if (key.length && !cur[1][key] && parts[i][0] === CLOSE && i === j) { | ||
if (key.length && !cur[1][key] && i === j | ||
&& (parts[i][0] === CLOSE || parts[i][0] === ATTR_BREAK)) { | ||
// https://html.spec.whatwg.org/multipage/infrastructure.html#boolean-attributes | ||
@@ -167,2 +168,3 @@ // empty string is falsy, not well behaved value in browser | ||
} else if (state === ATTR && /\s/.test(c)) { | ||
if (reg.length) res.push([ATTR_KEY,reg]) | ||
res.push([ATTR_BREAK]) | ||
@@ -179,8 +181,11 @@ } else if (state === ATTR_KEY && /\s/.test(c)) { | ||
reg += c | ||
} else if (state === ATTR_KEY_W && c === '=') { | ||
} else if ((state === ATTR_KEY_W || state === ATTR) && c === '=') { | ||
res.push([ATTR_EQ]) | ||
state = ATTR_VALUE_W | ||
} else if ((state === ATTR_KEY_W || state === ATTR) && !/\s/.test(c)) { | ||
res.push([ATTR_EQ]) | ||
state = ATTR | ||
res.push([ATTR_BREAK]) | ||
if (/[\w-]/.test(c)) { | ||
reg += c | ||
state = ATTR_KEY | ||
} else state = ATTR | ||
} else if (state === ATTR_VALUE_W && c === '"') { | ||
@@ -187,0 +192,0 @@ state = ATTR_VALUE_DQ |
{ | ||
"name": "hyperx", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "tagged template string virtual dom builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,1 +17,13 @@ var test = require('tape') | ||
}) | ||
test('boolean attribute followed by normal attribute', function (t) { | ||
var tree = hx`<video autoplay volume="50"></video>` | ||
t.equal(vdom.create(tree).toString(), '<video autoplay="autoplay" volume="50"></video>') | ||
t.end() | ||
}) | ||
test('boolean attribute preceded by normal attribute', function (t) { | ||
var tree = hx`<video volume="50" autoplay></video>` | ||
t.equal(vdom.create(tree).toString(), '<video volume="50" autoplay="autoplay"></video>') | ||
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
30180
762