@erickmerchant/framework
Advanced tools
Comparing version 41.2.2 to 41.3.0
49
main.js
@@ -25,4 +25,6 @@ const svgNamespace = 'http://www.w3.org/2000/svg' | ||
if (!meta._read) { | ||
Object.assign(meta, weakMap.get(target) ?? {}) | ||
const read = weakMap.get(target) | ||
Object.assign(meta, read ?? {}) | ||
meta._read = true | ||
@@ -34,33 +36,38 @@ } | ||
const writeMeta = (target, meta) => { | ||
if (meta._read) { | ||
weakMap.set(target, meta) | ||
} | ||
} | ||
const getNextSibling = (current) => current?.nextSibling | ||
const getListener = (key) => (e) => { | ||
const map = weakMap.get(e.target) | ||
const addListener = (document, type) => { | ||
document.addEventListener( | ||
type, | ||
(e) => { | ||
const map = weakMap.get(e.target) | ||
if (map && map[key]) { | ||
map[key](e) | ||
} | ||
if (map && map[type]) { | ||
map[type](e) | ||
} | ||
}, | ||
{capture: true} | ||
) | ||
} | ||
const morphAttribute = (target, key, value, meta, listeners) => { | ||
const document = target.ownerDocument | ||
const remove = value == null || value === false | ||
if (key.indexOf('on') === 0) { | ||
const type = key.substring(2) | ||
readMeta(target, meta) | ||
if (remove) { | ||
if (meta[key]) { | ||
meta[key] = null | ||
} | ||
} else { | ||
meta[key] = value | ||
meta[type] = remove ? null : value | ||
if (!listeners.includes(key)) { | ||
listeners.push(key) | ||
if (!remove && !listeners.includes(type)) { | ||
listeners.push(type) | ||
const type = key.substring(2) | ||
document.addEventListener(type, getListener(key), {capture: true}) | ||
} | ||
addListener(target.ownerDocument, type) | ||
} | ||
@@ -319,3 +326,3 @@ } else { | ||
if (meta._read) weakMap.set(target, meta) | ||
writeMeta(target, meta) | ||
} | ||
@@ -651,3 +658,3 @@ | ||
return Promise.resolve().then(() => { | ||
if (!viewCalled) { | ||
if (!viewCalled && view) { | ||
viewCalled = true | ||
@@ -654,0 +661,0 @@ |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "41.2.2", | ||
"version": "41.3.0", | ||
"description": "A front-end framework.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/erickmerchant/framework#readme", |
@@ -20,4 +20,3 @@ # @erickmerchant/framework | ||
const view = createDomView(target, (state) => { | ||
return html` | ||
const view = createDomView(target, (state) => html` | ||
<div> | ||
@@ -30,5 +29,5 @@ <output>${state}</output> | ||
` | ||
}) | ||
) | ||
app.render(view) | ||
``` |
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
19036
626
32