Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions css/css.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ type cssMinifier struct {

// Minifier is a CSS minifier.
type Minifier struct {
KeepCSS2 bool // DEPRECATED, use Version = 2
Precision int // number of significant digits
newPrecision int // precision for new numbers
Precision int // number of significant digits
newPrecision int // precision for new numbers
Inline bool
Version int
}
Expand Down Expand Up @@ -148,11 +147,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[stri
o.Inline = params != nil && params["inline"] == "1"
}
if o.Version <= 0 {
if o.KeepCSS2 {
o.Version = 2
} else {
o.Version = 3
}
o.Version = 3
}

z := parse.NewInput(r)
Expand Down
4 changes: 2 additions & 2 deletions css/css_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func TestCSSInline(t *testing.T) {
}
}

func TestCSSKeepCSS2(t *testing.T) {
func TestCSS2(t *testing.T) {
tests := []struct {
css string
expected string
Expand All @@ -458,7 +458,7 @@ func TestCSSKeepCSS2(t *testing.T) {

m := minify.New()
params := map[string]string{"inline": "1"}
cssMinifier := &Minifier{KeepCSS2: true}
cssMinifier := &Minifier{Version: 2}
for _, tt := range tests {
t.Run(tt.css, func(t *testing.T) {
r := bytes.NewBufferString(tt.css)
Expand Down
8 changes: 4 additions & 4 deletions svg/svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Minifier struct {
KeepComments bool
Precision int // number of significant digits
newPrecision int // precision for new numbers
Inline bool
inline bool
}

// Minify minifies SVG data, it reads from r and writes to w.
Expand All @@ -50,8 +50,8 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[stri
if o.newPrecision <= 0 || 15 < o.newPrecision {
o.newPrecision = 15 // minimum number of digits a double can represent exactly
}
if !o.Inline {
o.Inline = params != nil && params["inline"] == "1"
if !o.inline {
o.inline = params != nil && params["inline"] == "1"
}

// namespaces to keep
Expand Down Expand Up @@ -171,7 +171,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, params map[stri
val, _ = o.shortenDimension(val)
}
if attr == Xml_Space && bytes.Equal(val, []byte("preserve")) ||
tag == Svg && (o.Inline && attr == Xmlns ||
tag == Svg && (o.inline && attr == Xmlns ||
attr == Version && bytes.Equal(val, []byte("1.1")) ||
attr == X && bytes.Equal(val, zeroBytes) ||
attr == Y && bytes.Equal(val, zeroBytes) ||
Expand Down
2 changes: 1 addition & 1 deletion svg/svg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func TestSVGInline(t *testing.T) {
}

m := minify.New()
o := &Minifier{Inline: true}
o := &Minifier{inline: true}
for _, tt := range svgTests {
t.Run(tt.svg, func(t *testing.T) {
r := bytes.NewBufferString(tt.svg)
Expand Down
Loading