@erickmerchant/framework
Advanced tools
Comparing version 48.2.0 to 48.3.0
115
html.js
const weakMap = new WeakMap() | ||
const createAssertionError = (actual, expected) => | ||
Error(`Expected ${expected}. Found ${actual}.`) | ||
const throwAssertionError = (actual, expected) => { | ||
throw Error(`Expected ${expected}. Found ${actual}.`) | ||
} | ||
@@ -39,6 +40,8 @@ export const tokenTypes = [ | ||
*tokenize(acc, strs, vlength) { | ||
let str, i | ||
const current = () => str.charAt(i) | ||
const next = () => str.charAt(i + 1) | ||
let str, i, char | ||
const nextChar = () => { | ||
char = str.charAt(i++) | ||
} | ||
for (let index = 0, length = strs.length; index < length; index++) { | ||
@@ -48,21 +51,25 @@ str = strs[index] | ||
nextChar() | ||
let tag = acc.tag | ||
while (current()) { | ||
while (char) { | ||
if (!tag) { | ||
let value = '' | ||
if (current() === '<') { | ||
if (char === '<') { | ||
let end = false | ||
if (next() === '/') { | ||
nextChar() | ||
if (char === '/') { | ||
end = true | ||
i++ | ||
nextChar() | ||
} | ||
while (isNameChar(next())) { | ||
value += next() | ||
while (isNameChar(char)) { | ||
value += char | ||
i++ | ||
nextChar() | ||
} | ||
@@ -76,9 +83,7 @@ | ||
tag = value | ||
i++ | ||
} else { | ||
while (current() && current() !== '<') { | ||
value += current() | ||
while (char && char !== '<') { | ||
value += char | ||
i++ | ||
nextChar() | ||
} | ||
@@ -93,17 +98,21 @@ | ||
} | ||
} else if (isSpaceChar(current())) { | ||
i++ | ||
} else if (current() === '/' && next() === '>') { | ||
yield* [ | ||
END, | ||
{ | ||
type: tokenTypes.endtag, | ||
value: tag | ||
} | ||
] | ||
} else if (isSpaceChar(char)) { | ||
nextChar() | ||
} else if (char === '/') { | ||
nextChar() | ||
tag = false | ||
if (char === '>') { | ||
yield* [ | ||
END, | ||
{ | ||
type: tokenTypes.endtag, | ||
value: tag | ||
} | ||
] | ||
i += 2 | ||
} else if (current() === '>') { | ||
tag = false | ||
nextChar() | ||
} | ||
} else if (char === '>') { | ||
yield END | ||
@@ -113,12 +122,10 @@ | ||
i++ | ||
} else if (isNameChar(current())) { | ||
nextChar() | ||
} else if (isNameChar(char)) { | ||
let value = '' | ||
i-- | ||
while (isNameChar(char)) { | ||
value += char | ||
while (isNameChar(next())) { | ||
i++ | ||
value += current() | ||
nextChar() | ||
} | ||
@@ -131,4 +138,4 @@ | ||
if (next() === '=') { | ||
i++ | ||
if (char === '=') { | ||
nextChar() | ||
@@ -138,18 +145,18 @@ let quote = '' | ||
if (isQuoteChar(next())) { | ||
i++ | ||
if (isQuoteChar(char)) { | ||
quote = char | ||
quote = current() | ||
nextChar() | ||
while (next() !== quote) { | ||
if (next()) { | ||
i++ | ||
while (char !== quote) { | ||
if (char) { | ||
value += char | ||
value += current() | ||
nextChar() | ||
} else { | ||
throw createAssertionError('', quote) | ||
throwAssertionError('', quote) | ||
} | ||
} | ||
i++ | ||
nextChar() | ||
@@ -160,4 +167,4 @@ yield { | ||
} | ||
} else if (next()) { | ||
throw createAssertionError(next(), '"') | ||
} else if (char) { | ||
throwAssertionError(char, '"') | ||
} | ||
@@ -167,4 +174,2 @@ } else { | ||
} | ||
i++ | ||
} | ||
@@ -240,3 +245,3 @@ } | ||
} else { | ||
throw createAssertionError(token.type, END.type) | ||
throwAssertionError(token.type, END.type) | ||
} | ||
@@ -301,3 +306,3 @@ } | ||
} else if (token.type === tokenTypes.text && token.value.trim()) { | ||
throw createAssertionError(token.type, tokenTypes.node) | ||
throwAssertionError(token.type, tokenTypes.node) | ||
} | ||
@@ -307,3 +312,3 @@ } | ||
if (children.length !== 1) { | ||
throw createAssertionError(children.length, 1) | ||
throwAssertionError(children.length, 1) | ||
} | ||
@@ -310,0 +315,0 @@ |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "48.2.0", | ||
"version": "48.3.0", | ||
"description": "A front-end framework.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/erickmerchant/framework#readme", |
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
19251
538