Skip to content

Commit

Permalink
Add new flag; update readme (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
geotre authored Mar 2, 2023
1 parent 32c6139 commit 5418c93
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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).

0 comments on commit 5418c93

Please sign in to comment.