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:
|
else:
|
||||||
let res = diff(x.expanded, oldExpanded, parent, current, kxi)
|
let res = diff(x.expanded, oldExpanded, parent, current, kxi)
|
||||||
if res == usenewNode:
|
if res == usenewNode:
|
||||||
#oldNode[i] = newNode[i]
|
#kxi.addPatch(pkReplace, parent, current, x.expanded)
|
||||||
#kxi.addPatchV(oldNode, i, newNode[i])
|
discard "diff created a patchset for us, so this is fine"
|
||||||
kxi.addPatch(pkReplace, parent, current, x.expanded)
|
|
||||||
elif res != different:
|
elif res != different:
|
||||||
x.expanded = oldExpanded
|
x.expanded = oldExpanded
|
||||||
assert oldExpanded.dom != nil, "old expanded.dom is nil"
|
assert oldExpanded.dom != nil, "old expanded.dom is nil"
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ proc update(current, next: VComponent) =
|
||||||
let next = TextInput(next)
|
let next = TextInput(next)
|
||||||
current.value = next.value
|
current.value = next.value
|
||||||
current.guid = next.guid
|
current.guid = next.guid
|
||||||
next.isActive = current.isActive
|
#next.isActive = current.isActive
|
||||||
|
|
||||||
proc newTextInput*(style: VStyle = VStyle(); guid: cstring; value: cstring = cstring"",
|
proc newTextInput*(style: VStyle = VStyle(); guid: cstring; value: cstring = cstring"",
|
||||||
onchange: proc(v: cstring) = nil): TextInput =
|
onchange: proc(v: cstring) = nil): TextInput =
|
||||||
|
|
@ -107,10 +107,12 @@ var
|
||||||
proc renderPerson(text: cstring, index: int): VNode =
|
proc renderPerson(text: cstring, index: int): VNode =
|
||||||
proc select(ev: Event, n: VNode) =
|
proc select(ev: Event, n: VNode) =
|
||||||
selected = index
|
selected = index
|
||||||
|
errmsg = ""
|
||||||
|
|
||||||
result = buildHtml():
|
result = buildHtml():
|
||||||
tdiv(onClick=select):
|
tdiv:
|
||||||
text text
|
text text
|
||||||
|
button(onClick = select)
|
||||||
|
|
||||||
proc createDom(): VNode =
|
proc createDom(): VNode =
|
||||||
result = buildHtml(tdiv):
|
result = buildHtml(tdiv):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue