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] 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("