diff --git a/.gitignore b/.gitignore index 96bc49b..acb4ec1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ nimcache/ /tests/tester -/tools/karun +karax/tools/karun *.code-workspace *.exe diff --git a/karax.nimble b/karax.nimble index bc49e03..743d85b 100644 --- a/karax.nimble +++ b/karax.nimble @@ -9,6 +9,6 @@ license = "MIT" requires "nim >= 0.16.1" -skipDirs = @["examples", "experiments"] +skipDirs = @["examples", "experiments", "tests"] -bin = @["tools/karun"] +bin = @["karax/tools/karun"] diff --git a/karax/kajax.nim b/karax/kajax.nim index 800d315..80184d1 100644 --- a/karax/kajax.nim +++ b/karax/kajax.nim @@ -38,7 +38,7 @@ proc ajax*(meth, url: cstring; headers: openarray[(cstring, cstring)]; if this.status == 200: contWrapper(this.status, this.responseText) else: - contWrapper(this.status, this.statusText) + contWrapper(this.status, this.responseText) if useBinary: ajax.send(blob) else: diff --git a/karax/karax.nim b/karax/karax.nim index 19a7dfb..e353597 100644 --- a/karax/karax.nim +++ b/karax/karax.nim @@ -4,6 +4,9 @@ import kdom, vdom, jstrutils, compact, jdict, vstyles export kdom.Event, kdom.Blob +when defined(nimNoNil): + {.experimental: "notnil".} + proc kout*[T](x: T) {.importc: "console.log", varargs, deprecated.} ## the preferred way of debugging karax applications. Now deprecated, ## you can now use ``system.echo`` instead. @@ -135,6 +138,11 @@ proc vnodeToDom*(n: VNode; kxi: KaraxInstance): Node = if n.kind == VNodeKind.text: result = document.createTextNode(n.text) attach n + elif n.kind == VNodeKind.verbatim: + result = document.createElement("div") + result.innerHTML = n.text + attach n + return result elif n.kind == VNodeKind.vthunk: let x = callThunk(vcomponents[n.text], n) result = vnodeToDom(x, kxi) @@ -183,14 +191,17 @@ proc same(n: VNode, e: Node; nesting = 0): bool = if kxi.orphans.contains(n.id): return true if n.kind == VNodeKind.component: result = same(VComponent(n).expanded, e, nesting+1) + elif n.kind == VNodeKind.verbatim: + result = true elif n.kind == VNodeKind.vthunk or n.kind == VNodeKind.dthunk: # we don't check these for now: result = true elif toTag[n.kind] == e.nodename: result = true if n.kind != VNodeKind.text: - if e.len != n.len: - echo "expected ", e.len, " real ", n.len, toTag[n.kind], " nesting ", nesting + # BUGFIX: Microsoft's Edge gives the textarea a child containing the text node! + if e.len != n.len and n.kind != VNodeKind.textarea: + echo "expected ", n.len, " real ", e.len, " ", toTag[n.kind], " nesting ", nesting return false for i in 0 ..< n.len: if not same(n[i], e[i], nesting+1): return false @@ -239,6 +250,9 @@ proc eq(a, b: VNode): EqResult = if a.len != b.len: return different for i in 0..