/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/removeUselessStrokeAndFill.js (4359B)
'use strict'; const { visit, visitSkip, detachNodeFromParent } = require('../lib/xast.js'); const { collectStylesheet, computeStyle } = require('../lib/style.js'); const { elemsGroups } = require('./_collections.js'); exports.type = 'visitor'; exports.name = 'removeUselessStrokeAndFill'; exports.active = true; exports.description = 'removes useless stroke and fill attributes'; /** * Remove useless stroke and fill attrs. * * @author Kir Belevich * * @type {import('../lib/types').Plugin<{ * stroke?: boolean, * fill?: boolean, * removeNone?: boolean * }>} */ exports.fn = (root, params) => { const { stroke: removeStroke = true, fill: removeFill = true, removeNone = false, } = params; // style and script elements deoptimise this plugin let hasStyleOrScript = false; visit(root, { element: { enter: (node) => { if (node.name === 'style' || node.name === 'script') { hasStyleOrScript = true; } }, }, }); if (hasStyleOrScript) { return null; } const stylesheet = collectStylesheet(root); return { element: { enter: (node, parentNode) => { // id attribute deoptimise the whole subtree if (node.attributes.id != null) { return visitSkip; } if (elemsGroups.shape.includes(node.name) == false) { return; } const computedStyle = computeStyle(stylesheet, node); const stroke = computedStyle.stroke; const strokeOpacity = computedStyle['stroke-opacity']; const strokeWidth = computedStyle['stroke-width']; const markerEnd = computedStyle['marker-end']; const fill = computedStyle.fill; const fillOpacity = computedStyle['fill-opacity']; const computedParentStyle = parentNode.type === 'element' ? computeStyle(stylesheet, parentNode) : null; const parentStroke = computedParentStyle == null ? null : computedParentStyle.stroke; // remove stroke* if (removeStroke) { if ( stroke == null || (stroke.type === 'static' && stroke.value == 'none') || (strokeOpacity != null && strokeOpacity.type === 'static' && strokeOpacity.value === '0') || (strokeWidth != null && strokeWidth.type === 'static' && strokeWidth.value === '0') ) { // stroke-width may affect the size of marker-end // marker is not visible when stroke-width is 0 if ( (strokeWidth != null && strokeWidth.type === 'static' && strokeWidth.value === '0') || markerEnd == null ) { for (const name of Object.keys(node.attributes)) { if (name.startsWith('stroke')) { delete node.attributes[name]; } } // set explicit none to not inherit from parent if ( parentStroke != null && parentStroke.type === 'static' && parentStroke.value !== 'none' ) { node.attributes.stroke = 'none'; } } } } // remove fill* if (removeFill) { if ( (fill != null && fill.type === 'static' && fill.value === 'none') || (fillOpacity != null && fillOpacity.type === 'static' && fillOpacity.value === '0') ) { for (const name of Object.keys(node.attributes)) { if (name.startsWith('fill-')) { delete node.attributes[name]; } } if ( fill == null || (fill.type === 'static' && fill.value !== 'none') ) { node.attributes.fill = 'none'; } } } if (removeNone) { if ( (stroke == null || node.attributes.stroke === 'none') && ((fill != null && fill.type === 'static' && fill.value === 'none') || node.attributes.fill === 'none') ) { detachNodeFromParent(node, parentNode); } } }, }, }; };