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

Add new flag; update readme #244

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions karax/karax.nim
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ proc dodraw(kxi: KaraxInstance) =
let asdom = toDom(newtree, useAttachedNode = true, kxi)
replaceById(kxi.rootId, asdom)
else:
when not defined(release):
when not defined(debugKaraxSame):
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
let olddom = document.getElementById(kxi.rootId)
diff(newtree, kxi.currentTree, nil, olddom, kxi)
Expand All @@ -679,7 +679,7 @@ proc dodraw(kxi: KaraxInstance) =
echo ">>>>>>>>>>>>>>"
applyPatch(kxi)
kxi.currentTree = newtree
when not defined(release):
when not defined(debugKaraxSame):
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))

if not kxi.postRenderCallback.isNil:
Expand Down
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,5 +406,21 @@ let
option: text name
```

## Debugging

Karax will accept various compile time flags to add additional checks and debug info.

e.g. `nim js -d:debugKaraxDsl myapp.nim`

| flag name | description |
| --------------- | ----------- |
| debugKaraxDsl | prints the Nim code produced by the `buildHtml` macro to the terminal at compile time |
| debugKaraxSame | Ensures that the rendered html dom matches the expected output from the vdom. Note that some browser extensions will modify the page and cause false positives |
| karaxDebug* | prints debug info when checking the dom output and applying component state |
| stats* | track statistics about recursion depth when rendering |
| profileKarax* | track statistics about why nodes differ |

_* = used when debugging karax itself, not karax apps_

## License
MIT License. See [here](https://github.com/karaxnim/karax/blob/master/LICENSE.txt).