bugfix: better diff'ing for complex components
This commit is contained in:
parent
dc88eeaae3
commit
ec4a413a7b
2 changed files with 6 additions and 5 deletions
|
|
@ -411,9 +411,8 @@ proc diff(newNode, oldNode: VNode; parent, current: Node; kxi: KaraxInstance): E
|
|||
else:
|
||||
let res = diff(x.expanded, oldExpanded, parent, current, kxi)
|
||||
if res == usenewNode:
|
||||
#oldNode[i] = newNode[i]
|
||||
#kxi.addPatchV(oldNode, i, newNode[i])
|
||||
kxi.addPatch(pkReplace, parent, current, x.expanded)
|
||||
#kxi.addPatch(pkReplace, parent, current, x.expanded)
|
||||
discard "diff created a patchset for us, so this is fine"
|
||||
elif res != different:
|
||||
x.expanded = oldExpanded
|
||||
assert oldExpanded.dom != nil, "old expanded.dom is nil"
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ proc update(current, next: VComponent) =
|
|||
let next = TextInput(next)
|
||||
current.value = next.value
|
||||
current.guid = next.guid
|
||||
next.isActive = current.isActive
|
||||
#next.isActive = current.isActive
|
||||
|
||||
proc newTextInput*(style: VStyle = VStyle(); guid: cstring; value: cstring = cstring"",
|
||||
onchange: proc(v: cstring) = nil): TextInput =
|
||||
|
|
@ -107,10 +107,12 @@ var
|
|||
proc renderPerson(text: cstring, index: int): VNode =
|
||||
proc select(ev: Event, n: VNode) =
|
||||
selected = index
|
||||
errmsg = ""
|
||||
|
||||
result = buildHtml():
|
||||
tdiv(onClick=select):
|
||||
tdiv:
|
||||
text text
|
||||
button(onClick = select)
|
||||
|
||||
proc createDom(): VNode =
|
||||
result = buildHtml(tdiv):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue