From 80adfde3c830f734eb186a294f9d856c2df81593 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 3 Feb 2026 18:47:14 +0100 Subject: fix(dom): remove trailing slash for void element was never required for html --- dom/html_test.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'dom/html_test.go') diff --git a/dom/html_test.go b/dom/html_test.go index 39f6a1f..0fbd894 100644 --- a/dom/html_test.go +++ b/dom/html_test.go @@ -6,19 +6,18 @@ import ( ) func TestRender(t *testing.T) { - fn := func(tag string, attributes map[string]string, endSlash bool, expected string) func(*testing.T) { + fn := func(tag string, attributes map[string]string, expected string) func(*testing.T) { return func(t *testing.T) { t.Parallel() - got := string(render(tag, attributes, endSlash)) + got := string(render(tag, attributes)) if got != expected { t.Errorf("invalid value, got %s", got) } } } t.Run("render", func(t *testing.T) { - t.Run("simple", fn("p", map[string]string{}, false, "

")) - t.Run("endslash", fn("img", map[string]string{}, true, "")) - t.Run("attributes", fn("a", map[string]string{"href": "link"}, false, ``)) + t.Run("simple", fn("p", map[string]string{}, "

")) + t.Run("attributes", fn("a", map[string]string{"href": "link"}, ``)) }) } @@ -55,12 +54,12 @@ func TestVoidElement(t *testing.T) { } } t.Run("no_attributes", func(t *testing.T) { - t.Run("simple1", fn("br", nil, "
")) - t.Run("simple2", fn("img", nil, "")) + t.Run("simple1", fn("br", nil, "
")) + t.Run("simple2", fn("img", nil, "")) }) t.Run("attributes", func(t *testing.T) { - t.Run("one", fn("img", map[string]string{"src": "link"}, ``)) - t.Run("two", fn("img", map[string]string{"src": "link", "alt": "well"}, `well`)) + t.Run("one", fn("img", map[string]string{"src": "link"}, ``)) + t.Run("two", fn("img", map[string]string{"src": "link", "alt": "well"}, `well`)) }) } @@ -87,7 +86,7 @@ func TestContentElement(t *testing.T) { t.Run("no_attributes", func(t *testing.T) { t.Run("simple", fnLiteral("p", "", nil, `

`)) t.Run("literal", fnLiteral("p", "content", nil, `

content

`)) - t.Run("elements", fn("div", []Element{NewVoidElement("img"), NewVoidElement("br")}, nil, `

`)) + t.Run("elements", fn("div", []Element{NewVoidElement("img"), NewVoidElement("br")}, nil, `

`)) }) t.Run("attributes", func(t *testing.T) { t.Run("simple_one", fnLiteral("script", "", map[string]string{"src": "link"}, ``)) @@ -113,8 +112,8 @@ func TestElement_ClassList(t *testing.T) { } } t.Run("add", func(t *testing.T) { - t.Run("empty", fn(NewVoidElement("img"), ``)) - t.Run("one", fn(NewVoidElement("img"), ``, "bg")) - t.Run("two", fn(NewVoidElement("img"), ``, "bg", "large")) + t.Run("empty", fn(NewVoidElement("img"), ``)) + t.Run("one", fn(NewVoidElement("img"), ``, "bg")) + t.Run("two", fn(NewVoidElement("img"), ``, "bg", "large")) }) } -- cgit v1.2.3