diff --git a/experiments/example.nim b/experiments/example.nim index 78dcaae..61235f8 100644 --- a/experiments/example.nim +++ b/experiments/example.nim @@ -10,7 +10,6 @@ proc carousel*(key: VKey): VNode {.component.} = proc next(ev: Event; n: VNode) = counter = (counter + 1) mod images.len - markDirty key result = buildHtml(tdiv(key=key)): text images[counter] diff --git a/experiments/oldwidgets.nim b/experiments/oldwidgets.nim index 023dc98..c947d7f 100644 --- a/experiments/oldwidgets.nim +++ b/experiments/oldwidgets.nim @@ -201,3 +201,51 @@ proc visibleKeys(e: Node; a, b: var VKey; h, count: var int) = else: for i in 0..= 0 and dirty.contains(&newNode.key): - dirty.del(&newNode.key) - dec dirtyCount + if newNode.key >= 0 and isDirty(newNode.key): + unmarkDirty(newNode.key) let n = vnodeToDom(newNode) if parent == nil: replaceById("ROOT", n) @@ -241,9 +234,9 @@ proc dodraw() = let olddom = document.getElementById("ROOT") updateElement(nil, olddom, newtree, currentTree) #assert same(newtree, document.getElementById("ROOT")) - if dirtyCount > 0: + if someDirty: updateDirtyElements(nil, olddom, newtree) - dirtyCount = 0 + someDirty = false currentTree = newtree # now that it's part of the DOM, give it the focus: if toFocus != nil: