Handle exportSVG({ precision: 0 }) correctly

This commit is contained in:
Johan Sundström 2015-10-27 15:33:09 -07:00
parent f1257d83b2
commit 1b129feebf
2 changed files with 10 additions and 1 deletions

View file

@ -20,7 +20,7 @@ var Formatter = Base.extend(/** @lends Formatter# */{
* @param {Number} [precision=5] the amount of fractional digits
*/
initialize: function(precision) {
this.precision = precision || 5;
this.precision = precision == null ? 5 : precision;
this.multiplier = Math.pow(10, this.precision);
},

View file

@ -103,3 +103,12 @@ test('Export SVG polyline', function() {
}));
});
test('Export SVG path defaults to precision 5', function() {
var path = new Path('M0.123456789,1.9l0.8,1.1');
equals(path.exportSVG({}).getAttribute('d'), 'M0.12346,1.9l0.8,1.1');
});
test('Export SVG path at precision 0', function() {
var path = new Path('M0.123456789,1.9l0.8,1.1');
equals(path.exportSVG({ precision: 0 }).getAttribute('d'), 'M0,2l1,1');
});