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

AssertionError for editable <p> tag keydown event #86

Closed
liwt31 opened this issue Feb 14, 2019 · 2 comments
Closed

AssertionError for editable <p> tag keydown event #86

liwt31 opened this issue Feb 14, 2019 · 2 comments
Labels

Comments

@liwt31
Copy link

liwt31 commented Feb 14, 2019

Example:

include karax / prelude

proc createDom(): VNode =
  result = buildHtml(tdiv):
    p(contenteditable="true"):
      proc onKeydown =
        discard

setRenderer createDom

The code is compiled to JS and typing anything in the <p> tag results in the following error:

Uncaught Error: Error: unhandled exception: /home/wtli/Test/karax/karax/karax.nim(597, 14) `same(kxi.currentTree, getElementById(document, kxi.rootId), 0)`  [AssertionError]
Traceback (most recent call last)
redraw.:anonymous, line: 637
karax.dodraw, line: 597
system.failedAssertImpl, line: 3879
system.raiseAssert, line: 3872
sysFatal.sysFatal, line: 2918

    at unhandledException (test.js:920)
    at raiseException (test.js:672)
    at sys_fatal_20437 (test.js:974)
    at raise_assert_20432 (test.js:984)
    at failed_assert_impl_20481 (test.js:994)
    at dodraw_178631 (test.js:2634)
    at HEX3Aanonymous_180001 (test.js:2699)

Seems that when redraw is called the document tree and the karax instance tree is indeed different.

@bung87
Copy link
Contributor

bung87 commented May 24, 2021

workaround

include karax / prelude

var ins:KaraxInstance
proc createDom(): VNode =
  ins.surpressRedraws = true
  var editor = buildHtml:
    p(contenteditable="true"):
      proc onKeydown =
        discard
  var myEditor = vnodeToDom(editor)
  result = buildHtml(tdiv):
    dthunk(myEditor)

ins = setRenderer createDom

@geotre
Copy link
Collaborator

geotre commented Mar 2, 2023

Now that #244 is merged, the error will not trigger and the code should work as expected, with the inner text of the p elem only being written by Karax if the app itself changes the text (which this example does not do).

@geotre geotre closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants