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

Broken functionalities when karax used with grammarly or languagetool (and possibly other extensions) #232

Closed
pietroppeter opened this issue Nov 4, 2022 · 8 comments

Comments

@pietroppeter
Copy link

pietroppeter commented Nov 4, 2022

this came up in the forum today and it is only reported as an issue in nimforum (nim-lang/nimforum#303), but it is probably better also to have it here, since it is an issue to be fixed in karax.

In short:

  • extensions like grammarly or languagetool modify the dom and can corrupt nodes owned by karax
  • karax implemented functionalities fail as a result

we do still miss:

  • an understanding on how other virtual dom frameworks handle this case

we could probably benefit from:

  • a smaller reproducible example (other than working dircetly with nimforum)

also, what is the "knete" approach that @Araq was referring to in the linked nimforum issue?

@Araq
Copy link
Collaborator

Araq commented Nov 4, 2022

"Knete" is the working title for "Karax's DSL without the DOM diffing algorithm". The DSL simply produces real DOM nodes. Unfortunately this brings back all of the downsides of heavily state based programming. But it's still something I think is worthwhile to look into.

@geotre
Copy link
Collaborator

geotre commented Nov 4, 2022

Normally the dom looks like this:

image

The extension inserts elements alongside the textarea:

image

Causing exception

image

The exception is triggered by one of the doAssert same(...) calls (e.g. 1, 2, 3). I'm not sure which it is exactly because the forum is compiled with an older copy of Karax.

@geotre
Copy link
Collaborator

geotre commented Nov 4, 2022

Can reproduce the issue with something like this:

import std/dom
include pkg/karax/prelude

var val: cstring

proc draw: VNode =
  buildHtml(tdiv):
    textarea:
      proc onkeyup (ev: Event, n: VNode) =
        val = n.value
    p: text val

setRenderer draw, clientPostRenderCallback=proc =
  document.getElementById("ROOT").appendChild(document.createElement("p"))

Basically anything that adds elements as a descendant of the Karax root node

@Araq
Copy link
Collaborator

Araq commented Nov 4, 2022

Well you can diactivate the assertions and see if it works out...

@geotre geotre mentioned this issue Nov 29, 2022
@geotre
Copy link
Collaborator

geotre commented Dec 6, 2022

@pietroppeter this should be fixed now, do you want to test and close the issue?

@pietroppeter
Copy link
Author

hi, well, I was not suffering from that bug, I opened the issue to give visibility to this problem (and apparently it worked! ;)). People that are known to me to suffer from this issue are @tsoj (opened the original issue), and, as I learned today from discord, also @ringabout. Others that could help test this out?

@ringabout
Copy link
Collaborator

It can be closed; ref nim-lang/nimforum#335

@pietroppeter
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants