Merge branch 'master' of github.com:pragmagic/karax

This commit is contained in:
Araq 2019-09-26 21:01:54 +02:00
commit 9396b3e69d
14 changed files with 22 additions and 20 deletions

View file

@ -10,17 +10,17 @@ and some extensions that allow for an efficient component system.
These extensions are: These extensions are:
``VNodeKind.int`` ``VNodeKind.int``
The node havs a single integer field. The node has a single integer field.
``VNodeKind.bool`` ``VNodeKind.bool``
The node has a single boolean field. The node has a single boolean field.
``VNodeKint.vthunk`` ``VNodeKind.vthunk``
The node is a `virtual thunk`:idx:. This means there is a The node is a `virtual thunk`:idx:. This means there is a
function attached to it that produces the ``VNode`` structure function attached to it that produces the ``VNode`` structure
on demand. on demand.
``VNodeKint.dthunk`` ``VNodeKind.dthunk``
The node is a `DOM thunk`:idx:. This means there is a The node is a `DOM thunk`:idx:. This means there is a
function attached to it that produces the ``Node`` DOM structure function attached to it that produces the ``Node`` DOM structure
on demand. on demand.
@ -53,6 +53,6 @@ Event system
Karax does not abstract over the event system the DOM offers much: The same Karax does not abstract over the event system the DOM offers much: The same
``Event`` structure is used. Every callback has the ``Event`` structure is used. Every callback has the
signature ``proc (ev: Event; n: VNode)``. signature ``proc (ev: Event; n: VNode)`` or empty ``proc ()``.

View file

@ -9,7 +9,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/carousel.js"></script> <script type="text/javascript" src="carousel.js"></script>
</body> </body>
</html> </html>

View file

@ -9,7 +9,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/playerapp.js"></script> <script type="text/javascript" src="playerapp.js"></script>
</body> </body>
</html> </html>

View file

@ -9,7 +9,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/scrollapp.js"></script> <script type="text/javascript" src="scrollapp.js"></script>
</body> </body>
</html> </html>

View file

@ -10,7 +10,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/todoapp.js"></script> <script type="text/javascript" src="todoapp.js"></script>
</body> </body>
</html> </html>

View file

@ -9,5 +9,5 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/ajaxtest.js"></script> <script type="text/javascript" src="ajaxtest.js"></script>
</html> </html>

View file

@ -10,5 +10,5 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.0.2/echarts-en.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.0.2/echarts-en.js"></script>
<script type="text/javascript" src="nimcache/echartstest.js"></script> <script type="text/javascript" src="echartstest.js"></script>
</html> </html>

View file

@ -8,6 +8,6 @@
<body id="body"> <body id="body">
<div id="ROOT"></div> <div id="ROOT"></div>
<script type="text/javascript" src="nimcache/demo.js"></script> <script type="text/javascript" src="demo.js"></script>
</body> </body>
</html> </html>

View file

@ -10,7 +10,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/scrollapp.js"></script> <script type="text/javascript" src="scrollapp.js"></script>
<script type="text/javascript"> <script type="text/javascript">
onload(window.location.pathname.split('/')[1]) onload(window.location.pathname.split('/')[1])
</script> </script>

View file

@ -254,7 +254,10 @@ proc eq(a, b: VNode; recursive: bool): EqResult =
for i in 0..<a.len: for i in 0..<a.len:
if eq(a[i], b[i], recursive) == different: return different if eq(a[i], b[i], recursive) == different: return different
elif a.kind == VNodeKind.dthunk: elif a.kind == VNodeKind.dthunk:
return identical if a.dom == b.dom:
return identical
else: # fix #119
return different
elif a.kind == VNodeKind.verbatim: elif a.kind == VNodeKind.verbatim:
if a.text != b.text: if a.text != b.text:
return different return different

View file

@ -35,9 +35,8 @@ proc exec(cmd: string) =
proc build(name: string, rest: string, selectedCss: string, run: bool) = proc build(name: string, rest: string, selectedCss: string, run: bool) =
echo("Building...") echo("Building...")
createDir("nimcache") exec("nim js --out:" & name & ".js " & rest)
exec("nim js --out:nimcache/" & name & ".js " & rest) let dest = name & ".html"
let dest = "nimcache" / name & ".html"
writeFile(dest, html % [name, selectedCss]) writeFile(dest, html % [name, selectedCss])
if run: openDefaultBrowser(dest) if run: openDefaultBrowser(dest)

View file

@ -89,9 +89,9 @@ type
onanimationiteration, onanimationiteration,
onkeyupenter, ## vdom extension: an input field received the ENTER key press onkeyupenter, ## vdom extension: an input field received the ENTER key press
onkeyuplater ## vdom extension: a key was pressed and some time onkeyuplater, ## vdom extension: a key was pressed and some time
## passed (useful for on-the-fly text completions) ## passed (useful for on-the-fly text completions)
onload, # img
macro buildLookupTables(): untyped = macro buildLookupTables(): untyped =
var a = newTree(nnkBracket) var a = newTree(nnkBracket)

View file

@ -9,7 +9,7 @@
<div id="ROOT" /> <div id="ROOT" />
<script type="text/javascript" src="nimcache/diffDomTests.js"></script> <script type="text/javascript" src="diffDomTests.js"></script>
<script type="text/javascript"> <script type="text/javascript">
onload(window.location.pathname.split('/')[1]) onload(window.location.pathname.split('/')[1])
</script> </script>

View file

@ -8,6 +8,6 @@
</head> </head>
<body id="body"> <body id="body">
<div id="ROOT"></div> <div id="ROOT"></div>
<script src="nimcache/domEventTests.js" type="text/javascript"></script> <script src="domEventTests.js" type="text/javascript"></script>
</body> </body>
</html> </html>