| [ Web Proxy ] |
| Viewing: https://svgo.dev/docs/plugins/removeAttributesBySelector/ | [Back] [Original] |
Since v1.2.0Source
Removes specific attributes from elements that match a CSS selector.
module.exports = {
plugins: [
"removeAttributesBySelector"
]
}
module.exports = {
plugins: [
{
name: "removeAttributesBySelector",
params: {
selector: "[fill='#00ff00']",
attributes: "fill",
selectors: null
}
}
]
}
selectorA CSS selector that matches the elements to be modified.
attributesAn attribute, or array of attributes, to remove from the matched elements.
selectorsAn array of objects, each containing selector and attributes as described above. To match on more than one selector, use this parameter instead of the two above.
const svg = ` <?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox=" 0 0 150 100 " width="150"> <!-- Created with love! --> <defs> <ellipse cx="50" cy="50.0" rx="50.00" ry="auto" fill="black" id="circle"/> </defs> <g> <use href="#circle" transform="skewX(16)"/> <rect id="useless" width="0" height="0" fill="#ff0000"/> </g> </svg> `; const svgoConfig = { js2svg: { indent: 2, pretty: true }, plugins: [ "removeAttributesBySelector" ] } render(<SvgoPreview svg={svg} svgoConfig={svgoConfig}/>);
| Web Proxy Viewer | New URL | Original Page |