@erickmerchant/framework
Advanced tools
Comparing version 44.3.1 to 44.4.0
@@ -19,4 +19,2 @@ import {tokenTypes} from './html.js' | ||
const getNextSibling = (current) => current?.nextSibling | ||
const addListener = (document, type) => { | ||
@@ -66,3 +64,23 @@ document.addEventListener( | ||
const morph = (target, next, variables, isExistingElement, isSameView) => { | ||
const morph = ( | ||
target, | ||
next, | ||
variables, | ||
isExistingElement = true, | ||
isSameView = true | ||
) => { | ||
if (next.view) { | ||
const meta = readMeta(target) | ||
isSameView = next.view === meta.view | ||
if (next.dynamic || !isExistingElement || !isSameView) { | ||
meta.view = next.view | ||
variables = next.variables | ||
} else { | ||
return | ||
} | ||
} | ||
let attributeIndex = 0 | ||
@@ -165,5 +183,3 @@ | ||
if (next.view) { | ||
morphRoot(currentChild, next, !mode) | ||
} else if (mode || next.dynamic) { | ||
if (next.view || mode || next.dynamic) { | ||
morph(currentChild, next, variables, !mode, isSameView) | ||
@@ -179,3 +195,3 @@ } | ||
childNode = getNextSibling(currentChild) | ||
childNode = currentChild?.nextSibling | ||
} | ||
@@ -188,3 +204,3 @@ } | ||
do { | ||
nextChild = getNextSibling(childNode) | ||
nextChild = childNode?.nextSibling | ||
@@ -198,16 +214,4 @@ target.removeChild(childNode) | ||
const morphRoot = (target, next, isExistingElement = true) => { | ||
const meta = readMeta(target) | ||
const isSameView = next.view === meta.view | ||
if (next.dynamic || !isExistingElement || !isSameView) { | ||
meta.view = next.view | ||
morph(target, next, next.variables, isExistingElement, isSameView) | ||
} | ||
} | ||
export const createDOMView = (target, view) => (state) => { | ||
morphRoot(target, view(state)) | ||
morph(target, view(state)) | ||
} |
{ | ||
"name": "@erickmerchant/framework", | ||
"version": "44.3.1", | ||
"version": "44.4.0", | ||
"description": "A front-end framework.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/erickmerchant/framework#readme", |
554
16980