diff --git a/html/html.go b/html/html.go
index 73a03e1363..2fdc454baa 100644
--- a/html/html.go
+++ b/html/html.go
@@ -312,7 +312,17 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
if attrs[0] != nil && attrs[1] != nil {
attrs[1].Text = nil
}
- }
+ } else if t.Hash == html.Input {
+ attrs := tb.Attributes(html.Type, html.Value)
+ if t, value := attrs[0], attrs[1]; t != nil && value != nil {
+ isRadio := parse.EqualFold(t.AttrVal, []byte("radio"))
+ if !isRadio && len(value.AttrVal) == 0 {
+ value.Text = nil
+ } else if isRadio && parse.EqualFold(value.AttrVal, []byte("on")) {
+ value.Text = nil
+ }
+ }
+ }
// write attributes
htmlEqualIdName := false
@@ -343,8 +353,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
attr.Hash == html.Lang ||
attr.Hash == html.Name ||
attr.Hash == html.Title ||
- attr.Hash == html.Action && t.Hash == html.Form ||
- attr.Hash == html.Value && t.Hash == html.Input) {
+ attr.Hash == html.Action && t.Hash == html.Form) {
continue // omit empty attribute values
}
if attr.Traits&caselessAttr != 0 {
diff --git a/html/html_test.go b/html/html_test.go
index 077edcc0fc..dbd11eee32 100644
--- a/html/html_test.go
+++ b/html/html_test.go
@@ -51,6 +51,8 @@ func TestHTML(t *testing.T) {
{``, ``},
{``, ``},
{`
`, `
`},
+ {``, ``},
+ {``, ``},
// increase coverage
{``, ``},