about summary refs log tree commit diff stats
path: root/html
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-12-10 13:13:10 +0100
committerGitHub2020-12-10 13:13:10 +0100
commit100ae9e8308f380eeb3c6a5ea7a7e3277483aa43 (patch)
tree86176f9ef9393e6c06e7b8992b60176f1879fc3a /html
parenta76262652b227c95ce140f3698c46f59b79354ac (diff)
downloadgomponents-100ae9e8308f380eeb3c6a5ea7a7e3277483aa43.tar.lz
gomponents-100ae9e8308f380eeb3c6a5ea7a7e3277483aa43.tar.zst
gomponents-100ae9e8308f380eeb3c6a5ea7a7e3277483aa43.zip
Rename Document to Doctype (#54)
Diffstat (limited to 'html')
-rw-r--r--html/elements.go6
-rw-r--r--html/elements_test.go6
2 files changed, 6 insertions, 6 deletions
diff --git a/html/elements.go b/html/elements.go
index 8045561..4f1a0ec 100644
--- a/html/elements.go
+++ b/html/elements.go
@@ -14,13 +14,13 @@ func A(href string, children ...g.Node) g.NodeFunc {
 	return g.El("a", g.Attr("href", href), g.Group(children))
 }
 
-// Document returns an special kind of Node that prefixes its child with the string "<!doctype html>".
-func Document(child g.Node) g.NodeFunc {
+// Doctype returns a special kind of Node that prefixes its sibling with the string "<!doctype html>".
+func Doctype(sibling g.Node) g.NodeFunc {
 	return func(w io.Writer) error {
 		if _, err := w.Write([]byte("<!doctype html>")); err != nil {
 			return err
 		}
-		return child.Render(w)
+		return sibling.Render(w)
 	}
 }
 
diff --git a/html/elements_test.go b/html/elements_test.go
index e550bfe..f89919d 100644
--- a/html/elements_test.go
+++ b/html/elements_test.go
@@ -16,13 +16,13 @@ func (w *erroringWriter) Write(p []byte) (n int, err error) {
 	return 0, errors.New("don't want to write")
 }
 
-func TestDocument(t *testing.T) {
+func TestDoctype(t *testing.T) {
 	t.Run("returns doctype and children", func(t *testing.T) {
-		assert.Equal(t, `<!doctype html><html></html>`, Document(g.El("html")))
+		assert.Equal(t, `<!doctype html><html></html>`, Doctype(g.El("html")))
 	})
 
 	t.Run("errors on write error in Render", func(t *testing.T) {
-		err := Document(g.El("html")).Render(&erroringWriter{})
+		err := Doctype(g.El("html")).Render(&erroringWriter{})
 		assert.Error(t, err)
 	})
 }