Seth Falco
747cc722d9
chore: revamp how we export types ( #2118 )
2025-05-04 17:39:44 +01:00
Seth Falco
a8a53dbd90
chore: apply more eslint rules ( #2116 )
2025-05-02 10:00:37 +01:00
Seth Falco
8c593fab06
chore: bulk update all jsdoc and jsdoctypes ( #2114 )
2025-05-01 22:16:52 +01:00
Seth Falco
4573d0178e
chore: migrate plugin types to plugin ( #2111 )
2025-04-30 02:16:53 +01:00
johnkenny54
f7436c726e
fix: removeHiddenElems - treat <path> with opacity:0 as non-rendering node. ( #1948 )
2024-01-29 22:19:44 +00:00
johnkenny54
4da8b38fee
fix(removeHiddenElems): dont remove node if children have referenced id ( #1925 )
2024-01-06 14:55:24 +00:00
Jon Dufresne
2442f74239
chore: convert project to us ECMAScript modules (preserving CJS compatibility) ( #1905 )
2024-01-03 16:17:37 +00:00
Seth Falco
a3da8b3a76
refactor: use set in _collections ( #1899 )
2023-12-24 01:54:17 +00:00
Seth Falco
e6deecac90
fix: improve handling of url references in reference attributes ( #1881 )
2023-12-10 02:07:35 +00:00
Kendell R
2d9e101ded
fix(removeHiddenElems): handle defs better ( #1879 )
2023-12-09 22:25:30 +00:00
Seth Falco
e22d533be8
fix(removeHiddenElems): remove hidden definitions usage ( #1852 )
2023-11-26 20:55:35 +00:00
Seth Falco
f07e9de089
fix: resolve regression test for removeHiddenElems ( #1793 )
2023-09-25 19:04:06 +01:00
Bogdan Chadkin
e2e65cfc1e
Move plugin types into d.ts
2022-11-11 12:19:38 +03:00
Bogdan Chadkin
e6bd703b0a
Remove unused active and type fields from plugins
2022-10-08 23:39:58 +03:00
Bogdan Chadkin
79d4babcaf
Replace closestByName utility with visitSkip ( #1613 )
...
The last usage of closestByName utility based on node.parentNode
is removed here. One step closer to clean ast in v3.
2021-12-07 11:05:15 +03:00
Bogdan Chadkin
e4918ccdd1
Covert removeHiddenElems with types ( #1532 )
...
Covered removeHiddenElems plugin and big part of our code
- path parser and stringifier
- style manager
2021-08-21 14:55:05 +03:00
Bogdan Chadkin
07f8d606e0
Implement preset-default plugin ( #1513 )
...
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
}
}
}
]
}
```
2021-08-13 19:07:08 +03:00
Bogdan Chadkin
35b7356ff0
Pass parent node to visitor ( #1517 )
...
Wrapping each node with JSAPI class and passing parent to it is not
reliable. Parent may be changed but the reference will stay.
Here I wasn't able to detach comment from parent node for some reason.
Explicit parent node inferred while ast traverse is easier to debug and
work with. Eventually we will not need to wrap each node with JSAPI class.
2021-08-12 13:05:09 +03:00
Bogdan Chadkin
2c0c361074
Collect stylesheet once per plugin ( #1456 )
...
computeStyle(node) in isolation is quite slow utility because it
collects style elements across whole document, parses and sort them.
In this diff I splitted it into `collectStylesheet(root)` and
`computeStyle(stylesheet, node)` which are easy integrate with new
visitor plugin api.
2021-08-12 03:08:39 +03:00
Bogdan Chadkin
368a67b70f
Convert removeHiddenElems to visitor
2021-03-29 02:34:34 +03:00
Bogdan Chadkin
4cacd9e676
Migrate ast traversing into xast module ( #1434 )
...
Replaced JSAPI methods with new utilities
- querySelectorAll(node, selector)
- querySelector(node, selector)
- matches(node, selector)
- closestByName(node, elementName)
- traverse(node, fn)
New traverse replaced many in-place implementations.
2021-03-19 11:06:41 +03:00
Bogdan Chadkin
6f2f62c5ee
Access attributes directly ( #1433 )
...
Got rid from `.attrs`, `.attr()` and `.addAttr()` usages
2021-03-18 18:53:20 +03:00
Bogdan Chadkin
5314c12c99
Convert element children to xast
...
Ref https://github.com/syntax-tree/xast
Renamed content to children to match xast spec.
2021-03-11 12:29:13 +03:00
Bogdan Chadkin
e82a672bbf
Prepare root and element nodes for xast
...
Ref https://github.com/syntax-tree/xast
- added type: root | element
- renamed elem to name
- replaced "elem" property checks with check for correct type
2021-03-10 18:49:26 +03:00
Bogdan Chadkin
d3e3726ac4
Keep markers with display: none
2021-03-06 11:21:47 +03:00
Bogdan Chadkin
21c04e4d8a
Keep single point path for markers
2021-03-06 01:01:32 +03:00
Bogdan Chadkin
be28d65d78
Implement style computing ( #1399 )
...
Ref https://github.com/svg/svgo/issues/777
Currently a lot of optimisations are attributes specific and may be
broken because of inline or shared styles.
In this diff I'm trying to solve the problem with getComputedStyle
analog.
`computeStyle` collects attributes, shared css rules, inline styles
and inherited styles and checks whether they can be statically optimised
or left as deoptimisation.
2021-03-04 13:13:44 +03:00
XhmikosR
1310210d4e
Use https when possible and fix an inactive domain ( #1374 )
2021-02-25 13:48:18 +03:00
Bogdan Chadkin
d06747abca
Keep hidden elements if any descendant enables visibility
2021-02-25 00:05:26 +03:00
Bogdan Chadkin
9d67586787
Keep transparent elements inside <clipPath>
2021-02-24 22:58:00 +03:00
Bogdan Chadkin
9263d9ab90
Fix svg spec urls in plugins
2021-02-24 11:18:48 +03:00
Patryk Mikołajczyk
dd65b54019
fix
2018-03-23 21:39:46 +03:00
GreLI
a90ba46caf
Fixed paths removing. Fixes #413
2015-08-13 19:19:45 +03:00
GreLI
8ec45b7251
Don't remove path with exponent. Fixes #405
2015-07-18 20:37:48 +03:00
GreLI
a7f62d8984
Formatting
2015-06-21 19:13:41 +03:00
Yoshiya Hinosawa
8e6b365c40
Add --show-plugins option
2015-06-07 19:35:49 +09:00
GreLI
f651fd8de1
Fixed issues with multiple moveto coordinates on output. Fixes #338
2015-04-06 16:39:28 +03:00
GreLI
b3ee51c7bc
Fix path checking in removeHiddenElems. Fixes #333
2015-03-30 20:29:38 +03:00
GreLI
e94cb994dd
Remove incorrect <path> elems, not just empty
2015-03-22 21:20:20 +03:00
GreLI
5f892ee7dd
Don't remove empty elements which could be animated.
...
Resolves #213 .
2015-03-22 18:12:09 +03:00
deepsweet
2816424ed7
global refactoring dump
2013-04-09 22:06:27 +03:00
deepsweet
5485010269
'use strict' motherfucker! do you use it?!
2012-11-27 22:51:31 +02:00
deepsweet
291631509f
lib/jsAPI: simplification and refactoring
2012-10-15 08:28:25 +03:00
deepsweet
cec99ac1b3
plugins/removeHiddenElems: undo 'check for an empty values too'
2012-10-02 14:25:19 +04:00
deepsweet
ba1adb757c
plugins/removeHiddenElems: check for an empty values too
2012-10-02 13:46:24 +04:00
deepsweet
13af2ed95e
go!
2012-09-27 14:06:28 +03:00