From 3b460d9034faa059d32fc64441f225b7fda8e295 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 2 Jun 2015 22:31:54 +0200 Subject: [PATCH 1/2] Fix fore removing last ; followed by spaces --- src/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.js b/src/parser.js index f34a6fb91c2..5cb066a07c7 100644 --- a/src/parser.js +++ b/src/parser.js @@ -275,7 +275,7 @@ */ function parseStyleString(style, oStyle) { var attr, value; - style.replace(/;$/, '').split(';').forEach(function (chunk) { + style.replace(/;\s*$/, '').split(';').forEach(function (chunk) { var pair = chunk.split(':'); attr = normalizeAttr(pair[0].trim().toLowerCase()); From 452383594a81ad135b5614f860ce7323edbe0857 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 2 Jun 2015 23:05:54 +0200 Subject: [PATCH 2/2] Update parser.js --- test/unit/parser.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/parser.js b/test/unit/parser.js index 9a7939b15d1..5c65730ffd5 100644 --- a/test/unit/parser.js +++ b/test/unit/parser.js @@ -146,6 +146,17 @@ deepEqual(fabric.parseStyleAttribute(element), expectedObject); }); + test('parseStyleAttribute with trailing spaces', function() { + var element = fabric.document.createElement('path'); + element.setAttribute('style', 'left:10px; top:5px; '); + + var expectedObject = { + 'left': 10, + 'top': 5 + }; + deepEqual(fabric.parseStyleAttribute(element), expectedObject); + }); + test('parseStyleAttribute with value normalization', function() { var element = fabric.document.createElement('path'); element.setAttribute('style', 'fill:none; stroke-dasharray: 2 0.4;');