Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jul 23, 2023
1 parent 94fc76e commit 3fa4d56
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
var params map[string]string
if rawTagHash == Iframe {
mimetype = htmlMimeBytes
} else if len(rawTagMediatype) > 0 {
} else if 0 < len(rawTagMediatype) {
mimetype, params = parse.Mediatype(rawTagMediatype)
} else if rawTagHash == Script {
mimetype = jsMimeBytes
Expand Down Expand Up @@ -181,7 +181,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
if o.KeepWhitespace {
break
}
// remove when followed up by a block tag
// remove when followed by a block tag
if next.Traits&blockTag != 0 {
t.Data = t.Data[:len(t.Data)-1]
omitSpace = false
Expand Down Expand Up @@ -278,7 +278,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
omitSpace = true // omit spaces after block elements
}

if len(t.Data) > 3+len(t.Text) {
if 3+len(t.Text) < len(t.Data) {
t.Data[2+len(t.Text)] = '>'
t.Data = t.Data[:3+len(t.Text)]
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
for i := 0; i < len(content.AttrVal); i++ {
if content.AttrVal[i] == '=' && i+2 < len(content.AttrVal) {
i++
if n := parse.Number(content.AttrVal[i:]); n > 0 {
if n := parse.Number(content.AttrVal[i:]); 0 < n {
minNum := minify.Number(content.AttrVal[i:i+n], -1)
if len(minNum) < n {
copy(content.AttrVal[i:i+len(minNum)], minNum)
Expand Down Expand Up @@ -434,10 +434,10 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
if len(val) == 0 {
continue
}
} else if len(attr.Text) > 2 && attr.Text[0] == 'o' && attr.Text[1] == 'n' {
} else if 2 < len(attr.Text) && attr.Text[0] == 'o' && attr.Text[1] == 'n' {
// JS minifier for attribute inline code
val = parse.TrimWhitespace(val)
if len(val) >= 11 && parse.EqualFold(val[:11], jsSchemeBytes) {
if 11 <= len(val) && parse.EqualFold(val[:11], jsSchemeBytes) {
val = val[11:]
}
attrMinifyBuffer.Reset()
Expand Down Expand Up @@ -475,7 +475,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st

w.Write(spaceBytes)
w.Write(attr.Text)
if len(val) > 0 && attr.Traits&booleanAttr == 0 {
if 0 < len(val) && attr.Traits&booleanAttr == 0 {
w.Write(isBytes)

// use double quotes for RDFa attributes
Expand Down

0 comments on commit 3fa4d56

Please sign in to comment.