stephenlacy/daz

<img> doesn't need </img>

Closed this issue · 2 comments

I tried your project:

package main

import (
	"fmt"
	"github.com/stevelacy/daz"
)

func main() {
	img := daz.H("img", daz.Attr{"src": "https://www.sljfaq.org/images/birthdays.png"})
	body := daz.H("body", img)
	fmt.Printf("%s", daz.H("html", daz.H("head"), body)())
}

The output looks like this:

<html><head></head><body><img src='https://www.sljfaq.org/images/birthdays.png'></img></body></html>

You don't need </img> after the <img>.

The W3 validator gives an error on adding this input, so I would assume it's an error to add this. I looked at the source code but didn't see a way to switch that off.

Some other things which don't need an ending tag are

var noCloseTags = []string{
        "area",
        "br",
        "hr",
        "image",
        "input",
        "img",
        "link",
        "meta",
}

@benkasminbullock Thanks for reporting! Will add support for non-closing HTML tags

Thanks, fixed!