From 25062432fe0b5edfbd30579259e39f43ffa99ad6 Mon Sep 17 00:00:00 2001 From: Van Nhu Nguyen Date: Sat, 27 Apr 2019 11:55:29 +0200 Subject: [PATCH] Only add width/height attribute if in px --- premailer/element.go | 6 +++--- premailer/premailer_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/premailer/element.go b/premailer/element.go index 7dc9a24..3feaf28 100644 --- a/premailer/element.go +++ b/premailer/element.go @@ -62,7 +62,7 @@ func (er *elementRules) inline() { v := styles[p] final = append(final, fmt.Sprintf("%s:%s", p, v)) if er.cssToAttributes { - er.style_to_basic_html_attribute(p, v) + er.styleToBasicHtmlAttribute(p, v) } } @@ -73,7 +73,7 @@ func (er *elementRules) inline() { } -func (er *elementRules) style_to_basic_html_attribute(prop, value string) { +func (er *elementRules) styleToBasicHtmlAttribute(prop, value string) { switch prop { case "text-align": er.element.SetAttr("align", value) @@ -86,7 +86,7 @@ func (er *elementRules) style_to_basic_html_attribute(prop, value string) { case "height": if strings.HasSuffix(value, "px") { value = value[:len(value)-2] + er.element.SetAttr(prop, value) } - er.element.SetAttr(prop, value) } } diff --git a/premailer/premailer_test.go b/premailer/premailer_test.go index 8b374f5..3fe233a 100644 --- a/premailer/premailer_test.go +++ b/premailer/premailer_test.go @@ -93,7 +93,7 @@ func TestWithInline(t *testing.T) { -

Hi!

+

Hi!

Yes!

` @@ -103,7 +103,7 @@ func TestWithInline(t *testing.T) { result_html, err := p.Transform() assert.Nil(t, err) - assert.Contains(t, result_html, "

Hi!

") + assert.Contains(t, result_html, "

Hi!

") assert.Contains(t, result_html, "

Yes!

") assert.NotContains(t, result_html, "