From 794c3b26acbd3931b7973ff7e09a42b0ac414b1c Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Mon, 16 Nov 2020 12:38:24 +0100 Subject: Render correct HTML5 (#44) Previously, elements of kind void and empty elements generally would be rendered auto-closing (with a final `/` character in the start tag), which is allowed sometimes but arguably wrong. See https://dev.w3.org/html5/spec-LC/syntax.html#end-tags This created problems with for example `textarea` and `script`, which cannot be auto-closing, or the browser renders it wrong. Also clarified in the docs that this library outputs HTML5. Fixes #42.--- gomponents_test.go | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'gomponents_test.go') diff --git a/gomponents_test.go b/gomponents_test.go index 0c5dc68..26199c3 100644 --- a/gomponents_test.go +++ b/gomponents_test.go @@ -86,22 +86,33 @@ func (o outsider) Render(w io.Writer) error { func TestEl(t *testing.T) { t.Run("renders an empty element if no children given", func(t *testing.T) { e := g.El("div") - assert.Equal(t, "
", e) + assert.Equal(t, "", e) + }) + + t.Run("renders an empty element without closing tag if it's a void kind element", func(t *testing.T) { + e := g.El("hr") + assert.Equal(t, "