I still did get how id generation works but data flow is clear now at
least.
- covered with types
- migrated to visitor plugin api
- got rid of traverse api
I saw complaints about `extendDefaultPlugins` api
- it cannot be used when svgo is installed globally
- it requires svgo to be installed when using svgo-loader or svgo-jsx
- it prevents using serializable config formats like json
In this diff I introduced the new plugin which is a bundle of all
default plugins.
```js
module.exports = {
plugins: [
'preset_default',
// or
{
name: 'preset_default',
floatPrecision: 4,
overrides: {
convertPathData: {
applyTransforms: false
}
}
}
]
}
```
These iterators allows to directly manipulate passed value
which does not let us to get rid from legacy "attrs" field.
Object.entries makes it easier to get an access to both attribute
name and value.
Ref https://github.com/syntax-tree/xast
- added type: root | element
- renamed elem to name
- replaced "elem" property checks with check for correct type
cleanupIDs plugin is disabled when a script or style tag is present. I
assume that this is because they might contain an id.
If these tags are empty there is no point in not cleaning the id though.
When running svgo with the option `multipass: true`, it allows us to
first run `inlineStyles` plugin to empty the style tag. Then, we can run
`cleanupIDs` plugin.
Add parameter force to ignore style and script in cleanupIDs
Add tests for except=[ids] in cleanupIDs
Add parameter except in cleanupIDs to skip cleaning up specific ids
when running cleanupIds with minify:false option it does not save a reference to all ids and removes ids that shouldn't be removed.
This fix adds a var that keeps a ref to the original id even if minify is not defined