Skip to content

Commit

Permalink
add fix that switches off assertions on release, and uses the stored …
Browse files Browse the repository at this point in the history
…child dom nodes instead of getting them from the dom (#234)
  • Loading branch information
geotre authored Dec 1, 2022
1 parent 88487c8 commit 45bac6b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions karax/karax.nim
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ proc diff(newNode, oldNode: VNode; parent, current: Node; kxi: KaraxInstance) =
let pos = min(oldPos, newPos) + 1
# now the different children are in commonPrefix .. pos - 1:
for i in commonPrefix..pos-1:
diff(newNode[i], oldNode[i], current, current.childNodes[i], kxi)
diff(newNode[i], oldNode[i], current, oldNode[i].dom, kxi)

if oldPos + 1 == oldLength:
for i in pos..newPos:
Expand Down Expand Up @@ -665,7 +665,8 @@ proc dodraw(kxi: KaraxInstance) =
let asdom = toDom(newtree, useAttachedNode = true, kxi)
replaceById(kxi.rootId, asdom)
else:
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
when not defined(release):
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
let olddom = document.getElementById(kxi.rootId)
diff(newtree, kxi.currentTree, nil, olddom, kxi)
when defined(profileKarax):
Expand All @@ -678,7 +679,8 @@ proc dodraw(kxi: KaraxInstance) =
echo ">>>>>>>>>>>>>>"
applyPatch(kxi)
kxi.currentTree = newtree
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
when not defined(release):
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))

if not kxi.postRenderCallback.isNil:
kxi.postRenderCallback(rdata)
Expand Down

0 comments on commit 45bac6b

Please sign in to comment.