/var/www/flurhymez/node_modules/svgo/plugins
NameSizeModeActions
addAttributesToSVGElement.js20660644editdlrm
addClassesToSVGElement.js18330644editdlrm
cleanupAttrs.js14570644editdlrm
cleanupEnableBackground.js20140644editdlrm
cleanupIDs.js71450644editdlrm
cleanupListOfValues.js39960644editdlrm
cleanupNumericValues.js29560644editdlrm
collapseGroups.js39260644editdlrm
convertColors.js42220644editdlrm
convertEllipseToCircle.js9380644editdlrm
convertPathData.js283890644editdlrm
convertShapeToPath.js59830644editdlrm
convertStyleToAttrs.js38280644editdlrm
convertTransform.js116960644editdlrm
inlineStyles.js121820644editdlrm
mergePaths.js29940644editdlrm
mergeStyles.js23800644editdlrm
minifyStyles.js43890644editdlrm
moveElemsAttrsToGroup.js37410644editdlrm
moveGroupAttrsToElems.js17120644editdlrm
plugins.js32240644editdlrm
prefixIds.js65850644editdlrm
preset-default.js29900644editdlrm
removeAttributesBySelector.js24430644editdlrm
removeAttrs.js41910644editdlrm
removeComments.js6340644editdlrm
removeDesc.js10750644editdlrm
removeDimensions.js12270644editdlrm
removeDoctype.js11330644editdlrm
removeEditorsNSData.js20220644editdlrm
removeElementsByAttr.js21390644editdlrm
removeEmptyAttrs.js7770644editdlrm
removeEmptyContainers.js14910644editdlrm
removeEmptyText.js13890644editdlrm
removeHiddenElems.js92890644editdlrm
removeMetadata.js5660644editdlrm
removeNonInheritableGroupAttrs.js9250644editdlrm
removeOffCanvasPaths.js39670644editdlrm
removeRasterImages.js7750644editdlrm
removeScriptElement.js6010644editdlrm
removeStyleElement.js6040644editdlrm
removeTitle.js5790644editdlrm
removeUnknownsAndDefaults.js63460644editdlrm
removeUnusedNS.js18480644editdlrm
removeUselessDefs.js17240644editdlrm
removeUselessStrokeAndFill.js43590644editdlrm
removeViewBox.js14020644editdlrm
removeXMLNS.js6660644editdlrm
removeXMLProcInst.js6100644editdlrm
reusePaths.js33790644editdlrm
sortAttrs.js27220644editdlrm
sortDefsChildren.js18330644editdlrm
_applyTransforms.js98240644editdlrm
_collections.js444760644editdlrm
_path.js213580644editdlrm
_transforms.js107690644editdlrm
Edit: /var/www/flurhymez/node_modules/svgo/plugins/moveElemsAttrsToGroup.js (3741B)
'use strict'; const { visit } = require('../lib/xast.js'); const { inheritableAttrs, pathElems } = require('./_collections.js'); exports.type = 'visitor'; exports.name = 'moveElemsAttrsToGroup'; exports.active = true; exports.description = 'Move common attributes of group children to the group'; /** * Move common attributes of group children to the group * * @example * * * text * * * * ⬇ * * * text * * * * * @author Kir Belevich * * @type {import('../lib/types').Plugin} */ exports.fn = (root) => { // find if any style element is present let deoptimizedWithStyles = false; visit(root, { element: { enter: (node) => { if (node.name === 'style') { deoptimizedWithStyles = true; } }, }, }); return { element: { exit: (node) => { // process only groups with more than 1 children if (node.name !== 'g' || node.children.length <= 1) { return; } // deoptimize the plugin when style elements are present // selectors may rely on id, classes or tag names if (deoptimizedWithStyles) { return; } /** * find common attributes in group children * @type {Map} */ const commonAttributes = new Map(); let initial = true; let everyChildIsPath = true; for (const child of node.children) { if (child.type === 'element') { if (pathElems.includes(child.name) === false) { everyChildIsPath = false; } if (initial) { initial = false; // collect all inheritable attributes from first child element for (const [name, value] of Object.entries(child.attributes)) { // consider only inheritable attributes if (inheritableAttrs.includes(name)) { commonAttributes.set(name, value); } } } else { // exclude uncommon attributes from initial list for (const [name, value] of commonAttributes) { if (child.attributes[name] !== value) { commonAttributes.delete(name); } } } } } // preserve transform on children when group has clip-path or mask if ( node.attributes['clip-path'] != null || node.attributes.mask != null ) { commonAttributes.delete('transform'); } // preserve transform when all children are paths // so the transform could be applied to path data by other plugins if (everyChildIsPath) { commonAttributes.delete('transform'); } // add common children attributes to group for (const [name, value] of commonAttributes) { if (name === 'transform') { if (node.attributes.transform != null) { node.attributes.transform = `${node.attributes.transform} ${value}`; } else { node.attributes.transform = value; } } else { node.attributes[name] = value; } } // delete common attributes from children for (const child of node.children) { if (child.type === 'element') { for (const [name] of commonAttributes) { delete child.attributes[name]; } } } }, }, }; };