diff options
author | Markus Wüstenberg | 2020-11-16 12:38:24 +0100 |
---|---|---|
committer | GitHub | 2020-11-16 12:38:24 +0100 |
commit | 794c3b26acbd3931b7973ff7e09a42b0ac414b1c (patch) | |
tree | ac909b96ce6cca65b71828deca179db8e22e2995 /components | |
parent | 87d09c382434c9198c50356954fedf0ab8e5576f (diff) | |
download | gomponents-794c3b26acbd3931b7973ff7e09a42b0ac414b1c.tar.lz gomponents-794c3b26acbd3931b7973ff7e09a42b0ac414b1c.tar.zst gomponents-794c3b26acbd3931b7973ff7e09a42b0ac414b1c.zip |
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.
Diffstat (limited to 'components')
-rw-r--r-- | components/documents_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/components/documents_test.go b/components/documents_test.go index 2aabd5a..863ac96 100644 --- a/components/documents_test.go +++ b/components/documents_test.go @@ -20,7 +20,7 @@ func TestHTML5(t *testing.T) { Body: []g.Node{el.Div()}, }) - assert.Equal(t, `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>Hat</title><meta name="description" content="Love hats." /><link rel="stylesheet" href="/hat.css" /></head><body><div /></body></html>`, e) + assert.Equal(t, `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Hat</title><meta name="description" content="Love hats."><link rel="stylesheet" href="/hat.css"></head><body><div></div></body></html>`, e) }) t.Run("returns no language, description, and extra head/body elements if empty", func(t *testing.T) { @@ -28,6 +28,6 @@ func TestHTML5(t *testing.T) { Title: "Hat", }) - assert.Equal(t, `<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>Hat</title></head><body /></html>`, e) + assert.Equal(t, `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Hat</title></head><body></body></html>`, e) }) } |