From 8c966ad0deb9f833d2d3e03d64ffdc29fce09d23 Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Sat, 26 Aug 2023 09:49:26 +0200 Subject: [PATCH] SVG: keep attribute value when empty, see #576 --- svg/svg.go | 5 ----- svg/svg_test.go | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/svg/svg.go b/svg/svg.go index aaf43b2583..82f36e85b5 100644 --- a/svg/svg.go +++ b/svg/svg.go @@ -131,11 +131,6 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st case xml.AttributeToken: if t.Text == nil { // data is nil when attribute has been removed continue - } else if len(t.AttrVal) == 0 { - // empty attribute value - w.Write(spaceBytes) - w.Write(t.Text) - continue } attr := t.Hash diff --git a/svg/svg_test.go b/svg/svg_test.go index d75681e90e..10e6e4f1c5 100644 --- a/svg/svg_test.go +++ b/svg/svg_test.go @@ -32,7 +32,7 @@ func TestSVG(t *testing.T) { // TODO: what about x="" y="" for viewBox? //{``, ``}, {` `, ``}, - {` `, ``}, + {` `, ``}, {``, ``}, {"", ``}, {``, ``}, @@ -70,7 +70,7 @@ func TestSVG(t *testing.T) { {``, ``}, // #244 {``, ``}, // #244 {`
`, `
`}, // #291 - {``, ``}, // #576 + {``, ``}, // #576 // go fuzz {`<0 d=09e9.6e-9e0`, `<0 d="09e9.6e-9e0"`},