Self-closing tags (#133) (#134)

This commit is contained in:
Bùi Thành Nhân 2020-03-04 16:02:03 +07:00 • committed by GitHub
commit 7440393d3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,6 +45,10 @@ type
keygen, output, progress, meter, keygen, output, progress, meter,
details, summary, command, menu details, summary, command, menu
const selfClosing = {area, base, br, col, embed, hr, img, input,
link, meta, param, source, track, wbr}
type type
EventKind* {.pure.} = enum ## The events supported by the virtual DOM. EventKind* {.pure.} = enum ## The events supported by the virtual DOM.
onclick, ## An element is clicked. onclick, ## An element is clicked.
@ -434,6 +438,8 @@ proc add*(result: var string, n: VNode, indent = 0, indWidth = 2) =
result.add("</") result.add("</")
result.add(kind) result.add(kind)
result.add(">") result.add(">")
elif n.kind in selfClosing:
result.add(" />")
else: else:
result.add(">") result.add(">")
result.add("</") result.add("</")