Urara-Blog/node_modules/.pnpm-store/v3/files/78/89e89e2f5c2f1a548e02712f111d85492df106299986e29fb3e936ce8a0b5b86e21c2d9a4d4741ca1e9fdf94270e4d6861da18092e9a4ce09bf2704a34db0c
2022-08-14 01:14:53 +08:00

38 lines
925 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
exports.name = 'removeNonInheritableGroupAttrs';
exports.type = 'perItem';
exports.active = true;
exports.description =
'removes non-inheritable groups presentational attributes';
const {
inheritableAttrs,
attrsGroups,
presentationNonInheritableGroupAttrs,
} = require('./_collections');
/**
* Remove non-inheritable group's "presentation" attributes.
*
* @param {Object} item current iteration item
* @return {Boolean} if false, item will be filtered out
*
* @author Kir Belevich
*/
exports.fn = function (item) {
if (item.type === 'element' && item.name === 'g') {
for (const name of Object.keys(item.attributes)) {
if (
attrsGroups.presentation.includes(name) === true &&
inheritableAttrs.includes(name) === false &&
presentationNonInheritableGroupAttrs.includes(name) === false
) {
delete item.attributes[name];
}
}
}
};