-
Notifications
You must be signed in to change notification settings - Fork 89
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
Intervening elements are re-rendered if an element is added both before and after them #56
Comments
just ran into this and was puzzled by the results; this is a serious bug... here's a reduced case: include karax / prelude
import sugar
var page = 2
proc createDom(): VNode = buildHtml(tdiv):
if page == 3:
tdiv: text "Some text v3"
# else: tdiv: text "Some text v2" # uncomment would remove bug
button(onclick=() => (echo "click 2"; page = 2)): text "2"
button(onclick=() => (echo "click 3"; page = 3)): text "3"
tdiv: text "Some text2: " & $page # removing `& $page` would remove bug
setRenderer createDom click 3, then click 2: it should print:
but prints:
looks like dom diffing gets confused by the conditional inclusion of the node EDITjust checked, this is actually a recent regression caused by e422087 /cc @Araq
EDIT:
include karax / prelude
import sugar
var page = 2
proc createDom(): VNode = buildHtml(tdiv):
if page == 3:
tdiv: text "Some text v3"
# else: tdiv: text "Some text v2" # uncomment would remove bug
button(id = "id1", onclick=() => (echo "click 2"; page = 2)): text "2"
button(id = "id2", onclick=() => (echo "click 3"; page = 3)): text "3"
tdiv: text "Some text2: " & $page # removing `& $page` would remove bug
setRenderer createDom |
This was referenced Sep 13, 2019
This was referenced Sep 26, 2019
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example might explain better
Going from page 1 to page 2 or page 1 to page 3 works as expected. But page 1 to page 4 causes the input and buttons 1, 2 and 3 to be re-rendered.
The text was updated successfully, but these errors were encountered: