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

17 Commits

Author SHA1 Message Date
Bogdan Chadkin
dfc5b982c9 Rename master branch to main 2021-12-25 15:09:34 +03:00
Bogdan Chadkin
72b972261d
Refactor inlineStyles (#1601)
This is a big one

- got rid from another closestByName usage
- delegated removing empty defs elements to removeEmptyContainers plugin
- got rid from all css-tools usages (most inlineStyles code was there
  for some reason)
- combined a few loops
- fixed useMqs option (I would remove it in v3 for simplicity as it
  seems nobody use it)
2021-10-30 01:31:52 +03:00
Bogdan Chadkin
6cb2f7034f
Drop node.style usages (#1534)
Parsing inline styles with csstree in place is easier.
Caching does not add much value here.
2021-08-22 16:18:55 +03:00
Bogdan Chadkin
98c023bdb0
Drop node.class usages (#1533)
We are gonna remove everything outside of xast.
Here's dropped class prop.
2021-08-21 19:42:32 +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
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
07928fc77e
Replace removeAttr with delete operator (#1432)
delete operator is more explicit and not much harder to use.
2021-03-17 21:40:06 +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
318bd5b8fa
Forbid invalid <style> type attribute (#1400)
This fixes one more case in regression tests.
Also I added support for description in test cases.
This will let make tests more atomic.
2021-03-03 13:20:55 +03:00
Bogdan Chadkin
fd5e6406b1 Upgrade css-select 2021-02-16 19:14:20 +03:00
Stephanie Miller
e7b8a6ce7d Upgrade css-tree from alpha25 to alpha.28
API changed walkFoo(ast, fun) to walk(ast,{visit: 'Rule',enter: fun)
csstree.translate renamed to csstree.generate
csstree.generate throws an error on invalid style where translate silently ignored it - update style processing to catch and ignore instead
Updated tests - csstree now omits more whitespace
2018-09-15 14:43:28 +03:00
Lev Solntsev
ceccf1ffdc Fix inlineStyles working on foreignObject content. Fixes #823 2017-11-03 13:27:02 +03:00
strarsis
e25cf30fcb Add tests and fix for onlyMatchedOnce option cleaning classes/IDs that matched more than once.
Improve code.
2017-11-03 12:35:46 +03:00
GreLI
d828a62100 Bump dependencies and minor fix for inlineStyles 2017-10-22 22:30:17 +03:00
strarsis
2523799a12 Add inlineStyles plugin (rewrite of localStyles plugin) (#592)
Add inlineStyles plugin
2017-10-22 21:57:47 +03:00