1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

fix viewBox round

This commit is contained in:
caub
2017-06-14 12:03:14 +02:00
parent 19e2c9ac15
commit 8592d2080b
2 changed files with 5 additions and 4 deletions

View File

@ -41,8 +41,9 @@ exports.fn = function(item, params) {
if (item.hasAttr('viewBox')) {
var nums = item.attr('viewBox').value.split(/[ ,]/g);
item.attr('viewBox').value = nums.map(function(num) {
return +num.toFixed(floatPrecision);
item.attr('viewBox').value = nums.map(function(value) {
var num = +value;
return isNaN(num) ? value : +num.toFixed(floatPrecision);
}).join(' ');
}

View File

@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="50.12356%" height="20px" x=".2655" y="-.2346">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="20.000001 -19.99999 17.123456 70.708090" width="50.12356%" height="20px" x=".2655" y="-.2346">
<rect width="1in" heigth="12pt"/>
</svg>
@@@
<svg xmlns="http://www.w3.org/2000/svg" width="50.124%" height="20" x=".266" y="-.235">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="20 -20 17.123 70.708" width="50.124%" height="20" x=".266" y="-.235">
<rect width="96" heigth="16"/>
</svg>

Before

Width:  |  Height:  |  Size: 275 B

After

Width:  |  Height:  |  Size: 356 B