Comparing version 1.0.1 to 1.0.2
52
index.js
@@ -19,2 +19,4 @@ var VAR = 0, TEXT = 1, OPEN = 2, CLOSE = 3, ATTR = 4 | ||
if (xstate === ATTR_VALUE_SQ) xstate = ATTR_VALUE | ||
if (xstate === ATTR_VALUE_W) xstate = ATTR_VALUE | ||
if (xstate === ATTR) xstate = ATTR_KEY | ||
p.push([ VAR, xstate, arg ]) | ||
@@ -30,6 +32,5 @@ parts.push.apply(parts, p) | ||
var p = parts[i], s = p[0] | ||
var np = parts[i+1], ns = np && np[0] | ||
if (s === OPEN && /^\//.test(p[1])) { | ||
var ix = stack[stack.length-1][1] | ||
if (stack.length) { | ||
if (stack.length > 1) { | ||
stack.pop() | ||
@@ -42,20 +43,33 @@ stack[stack.length-1][0][2][ix] = h(cur[0], cur[1], cur[2]) | ||
stack.push([c,cur[2].length-1]) | ||
} else if (s === ATTR_KEY && (ns === ATTR_VALUE || ns === VAR)) { | ||
cur[1][p[1]] = strfn(np[ns === VAR ? 2 : 1]) | ||
i += 2 | ||
} else if (s === ATTR_KEY || (s === VAR && p[1] === ATTR_KEY)) { | ||
var key = '' | ||
for (; i < parts.length; i++) { | ||
var pj = parts[i], pjs = pj[0] | ||
if (pjs === ATTR_VALUE) { | ||
var sj = String(pj[1]) | ||
if (sj.length) cur[1][p[1]] += sj | ||
} else if (pjs === VAR && pj[1] === ATTR_VALUE) { | ||
var sj = String(pj[2]) | ||
if (sj.length) cur[1][p[1]] += sj | ||
if (parts[i][0] === ATTR_KEY) { | ||
key += String(parts[i][1]) | ||
} else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) { | ||
key += String(parts[i][2]) | ||
} else break | ||
} | ||
i-- | ||
for (; i < parts.length; i++) { | ||
if (parts[i][0] === ATTR_VALUE) { | ||
if (!cur[1][key]) cur[1][key] = strfn(parts[i][1]) | ||
else cur[1][key] += String(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 { | ||
i-- | ||
break | ||
} | ||
} | ||
} else if (s === ATTR_KEY) { | ||
cur[1][p[1]] = true | ||
} else if (s === VAR && p[1] === ATTR_KEY) { | ||
cur[1][p[2]] = true | ||
} else if (s === CLOSE) { | ||
//... | ||
if (selfClosing(cur[0]) && stack.length) { | ||
var ix = stack[stack.length-1][1] | ||
stack.pop() | ||
stack[stack.length-1][0][2][ix] = h(cur[0], cur[1], cur[2]) | ||
} | ||
} else if (s === VAR && p[1] === TEXT) { | ||
@@ -156,2 +170,5 @@ if (Array.isArray(p[2][0])) { | ||
reg = '' | ||
} else if (state === ATTR_KEY) { | ||
res.push([ATTR_KEY,reg]) | ||
reg = '' | ||
} | ||
@@ -175,1 +192,8 @@ return res | ||
} | ||
var closeRE = RegExp('^(' + [ | ||
'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', | ||
'frame', 'hr', 'img', 'input', 'isindex', 'keygen', 'link', 'meta', 'param', | ||
'source', 'track', 'wbr' | ||
].join('|') + ')$') | ||
function selfClosing (tag) { return closeRE.test(tag) } |
{ | ||
"name": "hyperx", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "tagged template string virtual dom builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
18531
21
426