1
0
mirror of https://github.com/svg/svgo.git synced 2026-01-27 07:02:06 +03:00
Commit Graph

30 Commits

Author SHA1 Message Date
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
9eb3af59f2 chore: drop parentNode property (#2113) 2025-05-01 15:59:23 +01:00
Seth Falco
1b4919a0d4 chore: stronger typing for xast/css-select code (#2112) 2025-04-30 14:41:07 +01:00
Seth Falco
4573d0178e chore: migrate plugin types to plugin (#2111) 2025-04-30 02:16:53 +01:00
Vlad Tansky
fea26379d2 fix: support -o-keyframes and -moz-keyframes (#2019) 2024-06-14 13:30:18 +01:00
Jon Dufresne
4bb3d8844f chore: Upgrade @types/css-tree to remove @ts-ignore comment (#1934) 2024-01-08 22:50:25 +00:00
Jon Dufresne
2442f74239 chore: convert project to us ECMAScript modules (preserving CJS compatibility) (#1905) 2024-01-03 16:17:37 +00:00
Jon Dufresne
4768af63e4 chore: Update @types/csso and correct types (#1910) 2023-12-27 13:09:56 +00:00
Seth Falco
c2cacc7060 chore: move health files to .github (#1906) 2023-12-27 12:54:30 +00:00
Seth Falco
a3da8b3a76 refactor: use set in _collections (#1899) 2023-12-24 01:54:17 +00:00
Seth Falco
22533f1ffe chore: update prettier and eslint (#1885) 2023-12-15 13:10:21 +00:00
Seth Falco
b740c07695 fix(inlineStyles): dont remove wrapper class if traversed (#1832) 2023-11-13 14:53:30 +00:00
Seth Falco
4c2cc1bbdb feat(inlineStyles): remove redundant presentation attrs (#1829)
SVGs can have the same presentation attribute declared redundantly in
both the node attributes and `<style>` tag.

This wouldn't break anything, but we can shave off a few more bytes by
dropping the attribute in this case.
2023-11-11 12:43:13 +00:00
Seth Falco
6d26482583 fix: skip keyframes with webkit prefix (#1826)
If an SVG features `keyframes` with the `-webkit` prefix, it would throw
an error before. This will treat them the same as regular `keyframes`.
2023-11-09 15:19:31 +00:00
Seth Falco
5aad38bcc7 fix(inlineStyles): empty css block created empty attribute (#1823)
When running this plugin on an SVG with an empty block in the CSS, it
would apply it to the matched elements by adding an empty `style`
attribute. See the test for an example.

This resolves that by just dropping the declaration if it's empty.
2023-11-07 23:20:48 +00:00
Bogdan Chadkin
12272958db Upgrade csso and csstree 2022-10-08 14:57:57 +03:00
Raphael Boidol
2ea65860f0 Remove stable package in favor of native stable sort (#1681) 2022-10-01 21:21:09 +03:00
Bogdan Chadkin
dfc5b982c9 Rename master branch to main 2021-12-25 15:09:34 +03:00
Bogdan Chadkin
79ceb09daf Avoid node.parentNode in style manager (#1576)
node.parentNode will be removed in v3 along with JSAPI class wrapper on
each node.

Style manager uses it to find inherited styles. To workaround this
I collected all parents along with all styles. This constraints style
manager to work only with initial ast which should not be a problem as
each plagin execution is isolated.
2021-09-21 19:11:53 +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
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
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
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
3e1bfd528d Convert attributes to xast with proxy fallback
There is a lot of attributes manipulation which is hard to remove at
once. In this diff I added `attributes` object and wrapped it as proxy
for `attrs` field.
2021-03-10 23:11:09 +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
c50decb438 Convert cdata and text nodes to xast
Ref https://github.com/syntax-tree/xast

More consistent naming and distinction by type looks a bit cleaner.
2021-03-10 16:16:11 +03:00
Bogdan Chadkin
ddbd7046b2 Ignore keyframes in computeStyle
Ref https://github.com/svg/svgo/issues/1408
2021-03-09 01:47:56 +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