Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vnode event move #257

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions karax/karax.nim
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ proc applyEvents(n: VNode) =
for i in 0..<len(n.events):
n.events[i][2] = wrapEvent(dest, n, n.events[i][0], n.events[i][1])

proc reapplyEvents(n: VNode) =
removeAllEventHandlers(n.dom)
applyEvents(n)

proc getVNodeById*(id: cstring; kxi: KaraxInstance = kxi): VNode =
## Get the VNode that was marked with ``id``. Returns ``nil``
## if no node exists.
Expand Down Expand Up @@ -388,6 +392,7 @@ proc addPatchV(kxi: KaraxInstance; parent: VNode; pos: int; newChild: VNode) =
proc moveDom(dest, src: VNode) =
dest.dom = src.dom
src.dom = nil
reapplyEvents(dest)
if dest.id != nil:
kxi.byId[dest.id] = dest
assert dest.len == src.len
Expand Down