Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
caiwuu committed Apr 10, 2024
1 parent 098bdce commit 51201f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/@typex-core/view/vdom/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ function updateChildren (parentElm, newCh, oldCh) {
let elmToMove
let before
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (oldStartVnode == null) {
if (oldStartVnode === null) {
oldStartVnode = oldCh[++oldStartIdx] // Vnode might have been moved left
} else if (oldEndVnode == null) {
} else if (oldEndVnode === null) {
oldEndVnode = oldCh[--oldEndIdx]
} else if (newStartVnode == null) {
} else if (newStartVnode === null) {
newStartVnode = newCh[++newStartIdx]
} else if (newEndVnode == null) {
} else if (newEndVnode === null) {
newEndVnode = newCh[--newEndIdx]
// 新头=旧头
} else if (sameVnode(newStartVnode, oldStartVnode)) {
Expand Down Expand Up @@ -207,6 +207,7 @@ function updateChildren (parentElm, newCh, oldCh) {
)
execHook(newStartVnode, 'onMounted')
} else {
console.log(111);
elmToMove = oldCh[idxInOld]
if (elmToMove.tag !== newStartVnode.tag) {
pluginContext.platform.insertBefore(
Expand All @@ -217,7 +218,7 @@ function updateChildren (parentElm, newCh, oldCh) {
execHook(newStartVnode, 'onMounted')
} else {
patchVnode(newStartVnode, elmToMove)
oldCh[idxInOld] = undefined
oldCh[idxInOld] = null
pluginContext.platform.insertBefore(
parentElm,
getElmByVnode(elmToMove),
Expand All @@ -230,7 +231,7 @@ function updateChildren (parentElm, newCh, oldCh) {
}

if (newStartIdx <= newEndIdx) {
before = newCh[newEndIdx + 1] == null ? null : getVdomOrElm(newCh[newEndIdx + 1])
before = newCh[newEndIdx + 1] === null ? null : getVdomOrElm(newCh[newEndIdx + 1])
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx)
}
if (oldStartIdx <= oldEndIdx) {
Expand Down Expand Up @@ -282,9 +283,6 @@ function patchVnode (vnode, oldVnode) {
// 重新映射elm和vn
const elm = getVdomOrElm(oldVnode)
setVdomOrElm(elm, vnode)
// 如果有ins则重新映射ins
// const ins = getVnodeOrIns(oldVnode)
// ins && setVnodeOrIns(vnode, ins)
const oldCh = oldVnode.children
const ch = vnode.children
// ins && execHook(ins, 'onBeforeupdate')
Expand Down
1 change: 1 addition & 0 deletions packages/@typex-platform/web/updateProps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import coreContext from '../../coreContext'
* @return {*}
*/
export default function updateProps (vnode, oldVnode) {
console.log(oldVnode);
if (typeof vnode.tag === 'function') return
const elm = coreContext.core.getVdomOrElm(vnode)
if (vnode.tag === 'text') {
Expand Down

0 comments on commit 51201f7

Please sign in to comment.