mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Preserve conditional processing attributes
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { attrsGroups } = require('./_collections.js');
|
||||
|
||||
exports.type = 'perItem';
|
||||
|
||||
exports.active = true;
|
||||
@ -14,16 +16,16 @@ exports.description = 'removes empty attributes';
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.fn = function(item) {
|
||||
|
||||
if (item.elem) {
|
||||
|
||||
item.eachAttr(function(attr) {
|
||||
if (attr.value === '') {
|
||||
item.removeAttr(attr.name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
exports.fn = function (item) {
|
||||
if (item.elem) {
|
||||
item.eachAttr(function (attr) {
|
||||
if (
|
||||
attr.value === '' &&
|
||||
// empty conditional processing attributes prevents elements from rendering
|
||||
attrsGroups.conditionalProcessing.includes(attr.name) === false
|
||||
) {
|
||||
item.removeAttr(attr.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user