diff --git a/libs/horizon/src/renderer/diff/nodeDiffComparator.ts b/libs/horizon/src/renderer/diff/nodeDiffComparator.ts index 82455159..d3033570 100644 --- a/libs/horizon/src/renderer/diff/nodeDiffComparator.ts +++ b/libs/horizon/src/renderer/diff/nodeDiffComparator.ts @@ -1,8 +1,8 @@ import type { VNode } from '../Types'; -import { FlagUtils, DirectAddition } from '../vnode/VNodeFlags'; +import { FlagUtils } from '../vnode/VNodeFlags'; import { TYPE_COMMON_ELEMENT, TYPE_FRAGMENT, TYPE_PORTAL } from '../../external/JSXElementType'; import { DomText, DomPortal, Fragment, DomComponent } from '../vnode/VNodeTags'; -import {updateVNode, createVNodeFromElement, updateVNodePath, createFragmentVNode, createPortalVNode, createDomTextVNode} from '../vnode/VNodeCreator'; +import {updateVNode, createVNodeFromElement, createFragmentVNode, createPortalVNode, createDomTextVNode} from '../vnode/VNodeCreator'; import { isSameType, getIteratorFn, @@ -270,7 +270,7 @@ function diffArrayNodesHandler( theLastPosition = setVNodeAdditionFlag(newNode, theLastPosition, isComparing); newNode.eIndex = leftIdx; newNode.cIndex = leftIdx; - updateVNodePath(newNode); + newNode.path = newNode.parent.path + newNode.cIndex; appendNode(newNode); oldNode = nextOldNode; } @@ -468,7 +468,7 @@ function setVNodesCIndex(startChild: VNode, startIdx: number) { while (node !== null) { node.cIndex = idx; - updateVNodePath(node); + node.path = node.parent.path + node.cIndex; node = node.next; idx++; } @@ -519,7 +519,7 @@ function diffStringNodeHandler( } newTextNode.parent = parentNode; newTextNode.cIndex = 0; - updateVNodePath(newTextNode); + newTextNode.path = newTextNode.parent.path + newTextNode.cIndex; return newTextNode; } @@ -597,7 +597,7 @@ function diffObjectNodeHandler( resultNode.parent = parentNode; resultNode.cIndex = 0; - updateVNodePath(resultNode); + resultNode.path = resultNode.parent.path + resultNode.cIndex; if (startDelVNode) { deleteVNodes(parentNode, startDelVNode); } diff --git a/libs/horizon/src/renderer/render/MemoComponent.ts b/libs/horizon/src/renderer/render/MemoComponent.ts index a0cd75f3..84daa883 100644 --- a/libs/horizon/src/renderer/render/MemoComponent.ts +++ b/libs/horizon/src/renderer/render/MemoComponent.ts @@ -1,7 +1,7 @@ import type {VNode} from '../Types'; import {mergeDefaultProps} from './LazyComponent'; -import {updateVNode, onlyUpdateChildVNodes, updateVNodePath, createFragmentVNode, createUndeterminedVNode} from '../vnode/VNodeCreator'; +import {updateVNode, onlyUpdateChildVNodes, createFragmentVNode, createUndeterminedVNode} from '../vnode/VNodeCreator'; import {shallowCompare} from '../utils/compare'; import { TYPE_FRAGMENT, @@ -29,7 +29,7 @@ export function captureMemoComponent( } newChild.parent = processing; newChild.ref = processing.ref; - updateVNodePath(newChild); + newChild.path = newChild.parent.path + newChild.cIndex; processing.child = newChild; return newChild; @@ -48,7 +48,7 @@ export function captureMemoComponent( const newChild = updateVNode(firstChild, newProps); newChild.parent = processing; newChild.cIndex = 0; - updateVNodePath(newChild); + newChild.path = newChild.parent.path + newChild.cIndex; newChild.ref = processing.ref; processing.child = newChild; diff --git a/libs/horizon/src/renderer/render/SuspenseComponent.ts b/libs/horizon/src/renderer/render/SuspenseComponent.ts index c2d6773b..cdc2f4a4 100644 --- a/libs/horizon/src/renderer/render/SuspenseComponent.ts +++ b/libs/horizon/src/renderer/render/SuspenseComponent.ts @@ -1,7 +1,7 @@ import type {VNode, PromiseType} from '../Types'; import {FlagUtils, Interrupted} from '../vnode/VNodeFlags'; -import {onlyUpdateChildVNodes, updateVNode, updateVNodePath, createFragmentVNode} from '../vnode/VNodeCreator'; +import {onlyUpdateChildVNodes, updateVNode, createFragmentVNode} from '../vnode/VNodeCreator'; import { ClassComponent, IncompleteClassComponent, @@ -44,7 +44,7 @@ function createFallback(processing: VNode, fallbackChildren) { fallbackFragment.parent = processing; fallbackFragment.eIndex = 1; fallbackFragment.cIndex = 1; - updateVNodePath(fallbackFragment); + fallbackFragment.path = fallbackFragment.parent.path + fallbackFragment.cIndex; processing.suspenseChildStatus = SuspenseChildStatus.ShowFallback; return fallbackFragment; @@ -76,7 +76,7 @@ function createSuspenseChildren(processing: VNode, newChildren) { childFragment.parent = processing; childFragment.cIndex = 0; - updateVNodePath(childFragment); + childFragment.path = childFragment.parent.path + childFragment.cIndex; processing.child = childFragment; processing.promiseResolve = false; return processing.child; diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/horizon/src/renderer/vnode/VNodeCreator.ts index b37fa3c7..35b1b354 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/horizon/src/renderer/vnode/VNodeCreator.ts @@ -157,10 +157,6 @@ export function createVNode(tag: VNodeTag | string, ...secondArg) { return vNode; } -export function updateVNodePath(vNode: VNode) { - vNode.path = vNode.parent.path + vNode.cIndex; -} - export function createVNodeFromElement(element: JSXElement): VNode { const type = element.type; const key = element.key; @@ -183,7 +179,7 @@ export function onlyUpdateChildVNodes(processing: VNode): VNode | null { let child: VNode | null = processing.child; while (child !== null) { updateVNode(child, child.props); - updateVNodePath(child); + child.path = child.parent.path + child.cIndex; child = child.next; } }