1
0
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:
Bogdan Chadkin
2021-03-06 13:18:53 +03:00
parent d3e3726ac4
commit a2b0e73767
3 changed files with 34 additions and 14 deletions

View File

@ -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);
}
});
}
};