diff --git a/bench_property_test.go b/bench_property_test.go index 8acf5bf..ee2d4cd 100644 --- a/bench_property_test.go +++ b/bench_property_test.go @@ -46,6 +46,6 @@ func BenchmarkHtml(b *testing.B) { sel := DocW().Find("h2") b.StartTimer() for i := 0; i < b.N; i++ { - sel.Html() + _, _ = sel.Html() } } diff --git a/utilities.go b/utilities.go index 656cf01..6d243cd 100644 --- a/utilities.go +++ b/utilities.go @@ -51,15 +51,16 @@ func nodeName(node *html.Node) string { case html.ElementNode, html.DoctypeNode: return node.Data default: - if node.Type >= 0 && int(node.Type) < len(nodeNames) { + if int(node.Type) < len(nodeNames) { return nodeNames[node.Type] } return "" } } -// Render renders the html of the first element from selector and writes it to the writer. -// // It behaves the same as OuterHtml but writes to w instead of returning the string. +// Render renders the html of the first element from selector and writes it to +// the writer. It behaves the same as OuterHtml but writes to w instead of +// returning the string. func Render(w io.Writer, s *Selection) error { if s.Length() == 0 { return nil diff --git a/utilities_test.go b/utilities_test.go index deaf34e..c8e9d54 100644 --- a/utilities_test.go +++ b/utilities_test.go @@ -80,6 +80,7 @@ func TestNodeNameMultiSel(t *testing.T) { t.Errorf("want %v, got %v", in, out) } } + func TestOuterHtml(t *testing.T) { doc, err := NewDocumentFromReader(strings.NewReader(allNodes)) if err != nil {