From 68907efd031fd8fc5103138e649e9069dfe03991 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sun, 8 Mar 2020 19:26:12 +0100 Subject: [PATCH] fix(svg_export): remove extra space from svg export #6205 (#6209) --- src/mixins/object.svg_export.js | 8 +++----- test/unit/text.js | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mixins/object.svg_export.js b/src/mixins/object.svg_export.js index 6dfe2ef1b20..05e83243abe 100644 --- a/src/mixins/object.svg_export.js +++ b/src/mixins/object.svg_export.js @@ -102,11 +102,9 @@ * @return {String} */ getSvgTextDecoration: function(style) { - if ('overline' in style || 'underline' in style || 'linethrough' in style) { - return (style.overline ? 'overline ' : '') + - (style.underline ? 'underline ' : '') + (style.linethrough ? 'line-through ' : ''); - } - return ''; + return ['overline', 'underline', 'line-through'].filter(function(decoration) { + return style[decoration.replace('-', '')]; + }).join(' '); }, /** diff --git a/test/unit/text.js b/test/unit/text.js index e4b1bed6664..d9ba9fd432c 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -645,7 +645,7 @@ overline: true, }; var styleString = iText.getSvgTextDecoration(styleObject); - var expected = 'overline '; + var expected = 'overline'; assert.equal(styleString, expected, 'style is as expected'); }); QUnit.test('getSvgTextDecoration with overline underline true produces correct output', function(assert){ @@ -655,7 +655,7 @@ underline: true, }; var styleString = iText.getSvgTextDecoration(styleObject); - var expected = 'overline underline '; + var expected = 'overline underline'; assert.equal(styleString, expected, 'style is as expected with overline underline'); }); QUnit.test('getSvgTextDecoration with overline underline true produces correct output', function(assert){ @@ -666,7 +666,7 @@ linethrough: true, }; var styleString = iText.getSvgTextDecoration(styleObject); - var expected = 'overline underline line-through '; + var expected = 'overline underline line-through'; assert.equal(styleString, expected, 'style is as expected with overline underline'); }); @@ -678,7 +678,7 @@ linethrough: true, }; var styleString = iText.getSvgTextDecoration(styleObject); - var expected = 'overline underline line-through '; + var expected = 'overline underline line-through'; assert.equal(styleString, expected, 'style is as expected with overline underline'); });