1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

plugins/cleanupEnableBackground doesn't catch floating-point numbers (fix #89)

This commit is contained in:
deepsweet
2013-01-18 15:34:19 +02:00
parent 30a3397a27
commit d120b1f0b7
3 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
var regEnableBackground = /^new\s0\s0\s(\d+)\s(\d+)$/, var regEnableBackground = /^new\s0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/,
elems = ['svg', 'mask', 'pattern']; elems = ['svg', 'mask', 'pattern'];
/** /**
@ -32,7 +32,7 @@ exports.cleanupEnableBackground = function(item) {
if (match) { if (match) {
if ( if (
item.attr('width').value === match[1] && item.attr('width').value === match[1] &&
item.attr('height').value === match[2] item.attr('height').value === match[3]
) { ) {
if (item.isElem('svg')) { if (item.isElem('svg')) {
item.removeAttr('enable-background'); item.removeAttr('enable-background');

View File

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="50" enable-background="new 0 0 100 50"> <svg xmlns="http://www.w3.org/2000/svg" width="100.5" height=".5" enable-background="new 0 0 100.5 .5">
test test
</svg> </svg>

Before

Width:  |  Height:  |  Size: 116 B

After

Width:  |  Height:  |  Size: 120 B

View File

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="50"> <svg xmlns="http://www.w3.org/2000/svg" width="100.5" height=".5">
test test
</svg> </svg>

Before

Width:  |  Height:  |  Size: 81 B

After

Width:  |  Height:  |  Size: 83 B