Simplify updateElement
This commit is contained in:
parent
4c582d7c06
commit
cd78f5085f
1 changed files with 5 additions and 6 deletions
|
|
@ -223,16 +223,15 @@ proc updateElement(parent, current: Node, newNode, oldNode: VNode) =
|
|||
dec rightNew
|
||||
dec rightOld
|
||||
|
||||
var nextChildPos = rightOld + 1
|
||||
var posNextElem = rightOld + 1
|
||||
var isPushBack = posNextElem == oldLength
|
||||
while left <= rightNew:
|
||||
if nextChildPos == oldLength:
|
||||
if isPushBack:
|
||||
current.appendChild(vnodeToDom(newNode[left]))
|
||||
else:
|
||||
current.insertBefore(vnodeToDom(newNode[left]), oldNode[rightOld + 1].dom)
|
||||
current.insertBefore(vnodeToDom(newNode[left]), oldNode[posNextElem].dom)
|
||||
# added new Node, so old state of VDOM have one more Node
|
||||
inc oldLength
|
||||
inc left
|
||||
inc nextChildPos
|
||||
|
||||
for i in left..rightOld:
|
||||
current.removeChild(oldNode[i].dom)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue