mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
plugins/cleanupEnableBackground: important fixes
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
var regEnableBackground = /^new\s0\s0\s(\d+)\s(\d+)$/,
|
var regEnableBackground = /^new\s0\s0\s(\d+)\s(\d+)$/,
|
||||||
container = require('./_collections').elems.container;
|
elems = ['svg', 'mask', 'pattern'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove or cleanup enable-background attr which coincides with a width/height box.
|
* Remove or cleanup enable-background attr which coincides with a width/height box.
|
||||||
@ -20,15 +20,16 @@ var regEnableBackground = /^new\s0\s0\s(\d+)\s(\d+)$/,
|
|||||||
exports.cleanupEnableBackground = function(item, params) {
|
exports.cleanupEnableBackground = function(item, params) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
item.isElem(container) &&
|
item.isElem(elems) &&
|
||||||
item.hasAttr('enable-background') &&
|
item.hasAttr('enable-background') &&
|
||||||
item.hasAttr('width') &&
|
item.hasAttr('width') &&
|
||||||
item.hasAttr('height')
|
item.hasAttr('height')
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
var match;
|
||||||
|
|
||||||
if (match = item.attr('enable-background').value.match(regEnableBackground)) {
|
if (match = item.attr('enable-background').value.match(regEnableBackground)) {
|
||||||
if (
|
if (
|
||||||
// TODO: not all containers have width/height attrs
|
|
||||||
item.attr('width').value == match[1] &&
|
item.attr('width').value == match[1] &&
|
||||||
item.attr('height').value == match[2]
|
item.attr('height').value == match[2]
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user