1
0
mirror of https://github.com/svg/svgo.git synced 2025-04-19 10:22:15 +03:00

31 Commits

Author SHA1 Message Date
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