Skip to content

Commit

Permalink
Fix parsing number values using scientific notation w/ a capital E. (#…
Browse files Browse the repository at this point in the history
…5731)

* Test parsing number values using scientific notation w/ a capital E.

* Fix parsing number values using scientific notation w/ a capital E.
  • Loading branch information
rodovich authored and asturur committed May 31, 2019
1 parent c16085b commit 6888a38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion HEADER.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fabric.SHARED_ATTRIBUTES = [
* Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.
*/
fabric.DPI = 96;
fabric.reNum = '(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)';
fabric.reNum = '(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)';
fabric.fontPaths = { };
fabric.iMatrix = [1, 0, 0, 1, 0, 0];

Expand Down
6 changes: 3 additions & 3 deletions test/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
assert.ok(fabric.parsePointsAttribute);

var element = fabric.document.createElement('polygon');
element.setAttribute('points', '10, 12 20 ,22, -0.52,0.001 2.3e2,2.3e-2, 10,-1 ');
element.setAttribute('points', '10, 12 20 ,22, -0.52,0.001 2.3e2,2.3E-2, 10,-1 ');

var actualPoints = fabric.parsePointsAttribute(element.getAttribute('points'));

Expand Down Expand Up @@ -304,9 +304,9 @@
parsedValue = fabric.parseTransformAttribute(element.getAttribute('transform'));
assert.deepEqual(parsedValue, [1,1.3820043381762832,0,1,0,0]);

element.setAttribute('transform', 'matrix(1,2,3,4,5,6)');
element.setAttribute('transform', 'matrix(1,2,3.3,-4,5E1,6e-1)');
parsedValue = fabric.parseTransformAttribute(element.getAttribute('transform'));
assert.deepEqual(parsedValue, [1,2,3,4,5,6]);
assert.deepEqual(parsedValue, [1,2,3.3,-4,50,0.6]);

element.setAttribute('transform', 'translate(21,31) translate(11,22)');
parsedValue = fabric.parseTransformAttribute(element.getAttribute('transform'));
Expand Down

0 comments on commit 6888a38

Please sign in to comment.