@erickmerchant/framework
Advanced tools
Comparing version 40.2.0 to 40.2.1
209
main.js
@@ -5,6 +5,10 @@ const svgNamespace = 'http://www.w3.org/2000/svg' | ||
const createQuoteError = (problem) => Error(`Quote ${problem}`) | ||
const createAssertionError = (actual, expected) => | ||
Error(`Expected ${expected}. Found ${actual}.`) | ||
const resolve = (obj) => { | ||
let afterUpdate | ||
if (typeof obj === 'function') { | ||
let afterUpdate | ||
if (typeof obj === 'function') { | ||
obj = obj((cb) => { | ||
@@ -14,5 +18,3 @@ afterUpdate = cb | ||
if (afterUpdate != null) { | ||
obj.afterUpdate = afterUpdate | ||
} | ||
obj.afterUpdate = afterUpdate | ||
} | ||
@@ -158,17 +160,15 @@ | ||
if (isSameView && !attribute.variable) { | ||
continue | ||
} | ||
if (!isSameView || attribute.variable) { | ||
let value = attribute.value | ||
let value = attribute.value | ||
if (attribute.variable) { | ||
value = variables[value] | ||
} | ||
if (attribute.variable) { | ||
value = variables[value] | ||
} | ||
if (attribute.key) { | ||
morphAttribute(target, attribute.key, value, meta, listeners) | ||
} else { | ||
for (const key of Object.keys(value)) { | ||
morphAttribute(target, key, value[key], meta, listeners) | ||
if (attribute.key) { | ||
morphAttribute(target, attribute.key, value, meta, listeners) | ||
} else { | ||
for (const key of Object.keys(value)) { | ||
morphAttribute(target, key, value[key], meta, listeners) | ||
} | ||
} | ||
@@ -194,97 +194,96 @@ } | ||
childNode = getNextSibling(childNode) | ||
} else { | ||
deopt = true | ||
continue | ||
} | ||
if (child.variable) { | ||
const variableValue = child.value | ||
deopt = true | ||
child = variables[variableValue] | ||
if (child.variable) { | ||
const variableValue = child.value | ||
if (child?.[Symbol.iterator] == null || typeof child === 'string') { | ||
child = [child] | ||
} | ||
child = variables[variableValue] | ||
let keyIndex = 0 | ||
let lengthDifference | ||
if (child?.[Symbol.iterator] == null || typeof child === 'string') { | ||
child = [child] | ||
} | ||
for (let grand of child) { | ||
grand = resolve(grand) | ||
let keyIndex = 0 | ||
let lengthDifference | ||
if (grand == null) grand = '' | ||
for (let grand of child) { | ||
grand = resolve(grand) | ||
let keysMatch = true | ||
if (grand == null) grand = '' | ||
if (grand.key != null) { | ||
if (!keys) { | ||
keys = {} | ||
let keysMatch = true | ||
readMeta(target, meta) | ||
if (grand.key != null) { | ||
if (!keys) { | ||
keys = {} | ||
prevKeys = meta.keys?.[variableValue] ?? {} | ||
} | ||
readMeta(target, meta) | ||
if (!keys[variableValue]) { | ||
keys[variableValue] = [] | ||
} | ||
prevKeys = meta.keys?.[variableValue] ?? {} | ||
} | ||
keys[variableValue].push(grand.key) | ||
if (!keys[variableValue]) { | ||
keys[variableValue] = [] | ||
} | ||
keysMatch = prevKeys[keyIndex] === grand.key | ||
keys[variableValue].push(grand.key) | ||
grand = grand.value | ||
keysMatch = prevKeys[keyIndex] === grand.key | ||
lengthDifference = child.length - prevKeys.length | ||
} | ||
grand = grand.value | ||
keyIndex++ | ||
lengthDifference = child.length - prevKeys.length | ||
} | ||
if (grand.type == null) { | ||
grand = {type: 'text', value: grand} | ||
} | ||
keyIndex++ | ||
if (!keysMatch && lengthDifference < 0 && childNode != null) { | ||
lengthDifference++ | ||
if (grand.type == null) { | ||
grand = {type: 'text', value: grand} | ||
} | ||
const extraNode = childNode | ||
if (!keysMatch && lengthDifference < 0 && childNode != null) { | ||
lengthDifference++ | ||
childNode = childNode.nextSibling | ||
const extraNode = childNode | ||
extraNode.remove() | ||
} | ||
childNode = childNode.nextSibling | ||
if (isSameView && grand.view != null && !grand.dynamic) { | ||
childNode = getNextSibling(childNode) | ||
} else { | ||
const forceAppend = | ||
!keysMatch && lengthDifference > 0 && childNode | ||
extraNode.remove() | ||
} | ||
if (forceAppend) { | ||
lengthDifference-- | ||
if (isSameView && grand.view != null && !grand.dynamic) { | ||
childNode = getNextSibling(childNode) | ||
} else { | ||
const forceAppend = !keysMatch && lengthDifference > 0 && childNode | ||
keyIndex-- | ||
} | ||
if (forceAppend) { | ||
lengthDifference-- | ||
keyIndex-- | ||
childNode = morphChild( | ||
target, | ||
childNode, | ||
grand, | ||
variables, | ||
isSameView, | ||
forceAppend, | ||
listeners | ||
) | ||
} | ||
childNode = morphChild( | ||
target, | ||
childNode, | ||
grand, | ||
variables, | ||
isSameView, | ||
forceAppend, | ||
listeners | ||
) | ||
} | ||
} else { | ||
childNode = morphChild( | ||
target, | ||
childNode, | ||
child, | ||
variables, | ||
isSameView, | ||
false, | ||
listeners | ||
) | ||
} | ||
} else { | ||
childNode = morphChild( | ||
target, | ||
childNode, | ||
child, | ||
variables, | ||
isSameView, | ||
false, | ||
listeners | ||
) | ||
} | ||
@@ -401,13 +400,5 @@ } | ||
i++ | ||
continue | ||
} | ||
if (tag && isSpaceChar(current())) { | ||
} else if (tag && isSpaceChar(current())) { | ||
i++ | ||
continue | ||
} | ||
if (tag && current() === '/' && next() === '>') { | ||
} else if (tag && current() === '/' && next() === '>') { | ||
yield* [ | ||
@@ -427,7 +418,3 @@ END, | ||
i += 2 | ||
continue | ||
} | ||
if (tag && current() === '>') { | ||
} else if (tag && current() === '>') { | ||
yield END | ||
@@ -440,7 +427,3 @@ | ||
i++ | ||
continue | ||
} | ||
if (tag && isOfKey(current())) { | ||
} else if (tag && isOfKey(current())) { | ||
let value = '' | ||
@@ -480,3 +463,3 @@ | ||
} else { | ||
throw Error('Quote mismatch') | ||
throw createQuoteError('mismatch') | ||
} | ||
@@ -492,3 +475,3 @@ } | ||
} else if (next()) { | ||
throw Error('Quote expected') | ||
throw createQuoteError('expected') | ||
} | ||
@@ -500,7 +483,3 @@ } else { | ||
i++ | ||
continue | ||
} | ||
if (!tag) { | ||
} else if (!tag) { | ||
let value = '' | ||
@@ -526,4 +505,2 @@ | ||
} | ||
continue | ||
} | ||
@@ -653,5 +630,5 @@ } | ||
if (children.length !== 1) { | ||
throw Error(`Found ${children.length} root nodes. Expected 1.`) | ||
throw createAssertionError(children.length, 1) | ||
} else if (children[0].type !== 'node') { | ||
throw Error(`Found '${children[0].type}'. Expected 'node'.`) | ||
throw createAssertionError(children[0].type, "'node'") | ||
} | ||
@@ -658,0 +635,0 @@ |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "40.2.0", | ||
"version": "40.2.1", | ||
"description": "A front-end framework.", | ||
@@ -31,11 +31,12 @@ "homepage": "https://github.com/erickmerchant/framework#readme", | ||
"devDependencies": { | ||
"@erickmerchant/eslint-config": "^1.1.2", | ||
"@babel/core": "^7.12.9", | ||
"@babel/eslint-parser": "^7.12.1", | ||
"@erickmerchant/eslint-config": "^2.0.0", | ||
"@erickmerchant/prettier-config": "^1.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"delay": "^4.4.0", | ||
"eslint": "^7.13.0", | ||
"eslint": "^7.14.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"jsdom": "^16.4.0", | ||
"prettier": "^2.1.2", | ||
"uvu": "^0.4.1" | ||
"prettier": "^2.2.0", | ||
"uvu": "^0.5.0" | ||
}, | ||
@@ -42,0 +43,0 @@ "engines": { |
18853
10
607