Skip to content

Commit 5418c93

Browse files
authored
Add new flag; update readme (#244)
1 parent 32c6139 commit 5418c93

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

karax/karax.nim

+2-2
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ proc dodraw(kxi: KaraxInstance) =
665665
let asdom = toDom(newtree, useAttachedNode = true, kxi)
666666
replaceById(kxi.rootId, asdom)
667667
else:
668-
when not defined(release):
668+
when not defined(debugKaraxSame):
669669
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
670670
let olddom = document.getElementById(kxi.rootId)
671671
diff(newtree, kxi.currentTree, nil, olddom, kxi)
@@ -679,7 +679,7 @@ proc dodraw(kxi: KaraxInstance) =
679679
echo ">>>>>>>>>>>>>>"
680680
applyPatch(kxi)
681681
kxi.currentTree = newtree
682-
when not defined(release):
682+
when not defined(debugKaraxSame):
683683
doAssert same(kxi.currentTree, document.getElementById(kxi.rootId))
684684

685685
if not kxi.postRenderCallback.isNil:

readme.md

+16
Original file line numberDiff line numberDiff line change
@@ -406,5 +406,21 @@ let
406406
option: text name
407407
```
408408

409+
## Debugging
410+
411+
Karax will accept various compile time flags to add additional checks and debug info.
412+
413+
e.g. `nim js -d:debugKaraxDsl myapp.nim`
414+
415+
| flag name | description |
416+
| --------------- | ----------- |
417+
| debugKaraxDsl | prints the Nim code produced by the `buildHtml` macro to the terminal at compile time |
418+
| 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 |
419+
| karaxDebug* | prints debug info when checking the dom output and applying component state |
420+
| stats* | track statistics about recursion depth when rendering |
421+
| profileKarax* | track statistics about why nodes differ |
422+
423+
_* = used when debugging karax itself, not karax apps_
424+
409425
## License
410426
MIT License. See [here](https://github.com/karaxnim/karax/blob/master/LICENSE.txt).

0 commit comments

Comments
 (0)