From 7440393d3a99c8f0bb49a4380fb84a7626b76951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B9i=20Th=C3=A0nh=20Nh=C3=A2n?= Date: Wed, 4 Mar 2020 16:02:03 +0700 Subject: [PATCH 1/2] Self-closing tags (#133) (#134) --- karax/vdom.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/karax/vdom.nim b/karax/vdom.nim index 321a455..3f44673 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -45,6 +45,10 @@ type keygen, output, progress, meter, details, summary, command, menu +const selfClosing = {area, base, br, col, embed, hr, img, input, + link, meta, param, source, track, wbr} + + type EventKind* {.pure.} = enum ## The events supported by the virtual DOM. onclick, ## An element is clicked. @@ -434,6 +438,8 @@ proc add*(result: var string, n: VNode, indent = 0, indWidth = 2) = result.add("") + elif n.kind in selfClosing: + result.add(" />") else: result.add(">") result.add(" Date: Thu, 12 Mar 2020 17:23:07 +0900 Subject: [PATCH 2/2] 3 tiny changes for "All Done" button. (#136) 1."onAllDone" callback fixation. Because the callback deletes all tasks instead of making them done, fixed. 2.Retouching checkbox and label property. Because a checkbox didn't work and label did'nt affect the checkbox, I set the callback on checkbox, and rename label's "for" property. 3.Adding Global var "doneswitch" for convinience. I guess the button should be able to make "All Done" and "All Undone" because the checkbox is not a button. So make it done, undone button interfaced with the checkbox's display. --- examples/todoapp/todoapp.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/todoapp/todoapp.nim b/examples/todoapp/todoapp.nim index b944de5..e3720fd 100644 --- a/examples/todoapp/todoapp.nim +++ b/examples/todoapp/todoapp.nim @@ -9,7 +9,7 @@ var selectedEntry = -1 filter: Filter entriesLen: int - + doneswitch = true const contentSuffix = cstring"content" completedSuffix = cstring"completed" @@ -62,9 +62,9 @@ proc toggleEntry(ev: Event; n: VNode) = markAsCompleted(id, not isCompleted(id)) proc onAllDone(ev: Event; n: VNode) = - clear() - selectedEntry = -1 - + for i in 0..