mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
@ -40,7 +40,7 @@ exports.fn = function(item, params) {
|
|||||||
var floatPrecision = params.floatPrecision;
|
var floatPrecision = params.floatPrecision;
|
||||||
|
|
||||||
if (item.hasAttr('viewBox')) {
|
if (item.hasAttr('viewBox')) {
|
||||||
var nums = item.attr('viewBox').value.split(/[ ,]/g);
|
var nums = item.attr('viewBox').value.split(/\s,?\s*|,\s*/g);
|
||||||
item.attr('viewBox').value = nums.map(function(value) {
|
item.attr('viewBox').value = nums.map(function(value) {
|
||||||
var num = +value;
|
var num = +value;
|
||||||
return isNaN(num) ? value : +num.toFixed(floatPrecision);
|
return isNaN(num) ? value : +num.toFixed(floatPrecision);
|
||||||
@ -50,7 +50,7 @@ exports.fn = function(item, params) {
|
|||||||
item.eachAttr(function(attr) {
|
item.eachAttr(function(attr) {
|
||||||
// The `version` attribute is a text string and cannot be rounded
|
// The `version` attribute is a text string and cannot be rounded
|
||||||
if (attr.name === 'version') { return }
|
if (attr.name === 'version') { return }
|
||||||
|
|
||||||
var match = attr.value.match(regNumericValues);
|
var match = attr.value.match(regNumericValues);
|
||||||
|
|
||||||
// if attribute value matches regNumericValues
|
// if attribute value matches regNumericValues
|
||||||
|
9
test/plugins/cleanupNumericValues.02.svg
Normal file
9
test/plugins/cleanupNumericValues.02.svg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0, 0, 20, 20">
|
||||||
|
<rect width="20" height="20" fill="rgba(255,255,255,.85)" rx="20"/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
@@@
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
|
||||||
|
<rect width="20" height="20" fill="rgba(255,255,255,.85)" rx="20"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 335 B |
Reference in New Issue
Block a user