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

365 Commits

Author SHA1 Message Date
Seth Falco
6996fca1a6 refactor: improve performance of stringifyPathData (#1900) 2023-12-24 23:05:12 +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
e6deecac90 fix: improve handling of url references in reference attributes (#1881) 2023-12-10 02:07:35 +00:00
Jon Dufresne
d6ff70baf9 chore: fix several typos (#1868) 2023-12-03 18:02:22 +00:00
Gordon Franke
3f2bcb48d5 fix: output profit in red if file size increased (#1162) 2023-11-27 14:24:58 +00:00
Sebastian Krah
4d15ef2be9 fix: use .d.ts file extension for type definitions (#1780) 2023-11-26 23:38:52 +00:00
nuintun
25dc073ed3 feat: improve loadConfig types (#1844) 2023-11-26 23:26:10 +00:00
Seth Falco
e22d533be8 fix(removeHiddenElems): remove hidden definitions usage (#1852) 2023-11-26 20:55:35 +00:00
johnkenny54
8879fcbbab test: fix crlf unit tests (#1850) 2023-11-26 15:27:28 +00:00
Bogdan Chadkin
9fca7be551 feat(removeXlink): new plugin to map xlink attrs to svg 2 2023-11-18 16:29:20 +00:00
Seth Falco
b740c07695 fix(inlineStyles): dont remove wrapper class if traversed (#1832) 2023-11-13 14:53:30 +00:00
Seth Falco
1f766ac509 fix(convertPathData): skip if transform overridden in styles (#1830) 2023-11-12 14:54:55 +00:00
Seth Falco
a9df915d1d fix: dont trim pre elements (#1796)
Includes pre in the array of text elements in _collections.js so that we don't trim whitespace on them, which effects rendering.
2023-11-12 11:56:39 +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
Seth Falco
e21e56060b feat(removeScriptElement): add all known event types (#1819)
Update the list of event attributes to include everything listed on MDN.
2023-11-04 14:07:29 +00:00
Seth Falco
1df2e0fa39 fix(cleanupIds): skip generated ids for malformed references (#1817)
I also had some chores pending which were trivial individually, I opted
to incorporate them here as well.

* In JSDocs, use the nullable syntax as it's more concise and familiar
from TypeScript usage.
* discord → Discord (proper nouns should match capitalization)
* Use actions/checkout v4 instead of v2
2023-11-04 12:56:20 +00:00
Seth Falco
c51dcfa6bb fix: warn and do not crash on null plugin (#1803)
If we received null/undefined/empty plugins, instead of crashing, log a
warning and ignore them.
2023-10-22 14:11:34 +01:00
Seth Falco
6eac770ba5 feat: convert one stop gradients plugin (#1790)
Detects if a redundant linearGradient or radialGradient is used with
only a single stop, which effectively means a solid color.

If this is found, just remove the gradient and replace references to it
with the color of the first and only stop defined.
2023-10-22 13:53:39 +01:00
Seth Falco
3966c10565 refactor: create hasScripts util (#1809)
Introduces a hasScript utility which can be reused to consistently check for scripts, whereas before different plugins performed this check differently.
2023-10-22 10:58:03 +01:00
Seth Falco
e529c6674d fix(removeDesc): removeAny should be disabled by default (#1806)
As the description of the plugin states, it should only remove the
description if we can see it's just editor attribution, since this
element is used for accessibility.

In general, accessibility is more important than optimizations, so while
I could update the documentation to reflect this behavior, I believe the
default should be changed back.
2023-10-04 11:45:06 +01:00
Seth Falco
02c7a78536 fix(convertTransform): do not add redundant space between functions (#1802)
The space is optional between transform functions in the `transform`
attribute and similar properties. This just omits the space as a
micro-optimization.

This does not add new tests is the scenario is covered adequately in
existing tests.

Also refactors js2transform to avoid concatenating in a loop.
2023-09-27 17:20:10 +01:00
Marvin Hagemeister
aa5d667fcb Speed up stringifyNumber (#1717)
I'm currently profiling my build setup and noticed that
`stringifyNumber` pops up here and there. Instead of going with the
double regex replace approach, we'll go with the faster approach in
`removeLeadingZero`.

In total the changes in this PR speed up the build by about `0.9s` in my
project.

<img width="798" alt="stringifyNumber"
src="https://user-images.githubusercontent.com/1062408/204154146-ce67d0c9-faf2-40a1-8186-8d34caea74a5.png">
2022-11-30 11:53:51 +03:00
Bogdan Chadkin
422fa142f2 Reuse plugin types for config 2022-11-11 12:50:33 +03:00
Bogdan Chadkin
6295c60fbf Rename cleanupIDs to cleanupIds for consistency with prefixIds 2022-10-23 11:54:48 +03:00
Bogdan Chadkin
53ed57c7e1 Expose typescript types 2022-10-17 00:10:39 +03:00
Bogdan Chadkin
5857816a5a Remove result.info.width and result.info.height 2022-10-10 01:32:12 +03:00
Bogdan Chadkin
420ae9d8a1 Throw SvgoParserError 2022-10-10 00:33:19 +03:00
Bogdan Chadkin
dd9cad1cf9 Add sortAttrs to default preset 2022-10-09 17:29:11 +03:00
Bogdan Chadkin
f649eabf6d Remove active flag in plugin config 2022-10-08 19:42:29 +03:00
Bogdan Chadkin
2d1c12c754 Remove returning ast from invoker 2022-10-08 19:16:18 +03:00
Bogdan Chadkin
12272958db Upgrade csso and csstree 2022-10-08 14:57:57 +03:00
Bogdan Chadkin
075ab164f6 Store builtin plugins as an array 2022-10-02 22:58:02 +03:00
Bogdan Chadkin
954faf3c87 Remove default plugin.params support 2022-10-02 19:43:06 +03:00
Bogdan Chadkin
97553d83b6 Replace list of default plugins with default preset 2022-10-02 15:06:45 +03:00
Bogdan Chadkin
de5d68201b Drop full, perItem and perItemReverse plugin types 2022-10-02 14:53:34 +03:00
Bogdan Chadkin
acf103251c Fix encode without multipass 2022-10-02 13:15:29 +03:00
Bogdan Chadkin
d5a8555781 Drop node 10 require fallback when load config 2022-10-02 12:15:41 +03:00
Bogdan Chadkin
516c6e1fc1 Drop createContentItem from public api and JSAPI node wrappers 2022-10-02 12:00:44 +03:00
Bogdan Chadkin
50e836d5a4 Drop class list handler 2022-10-02 11:10:45 +03:00
Bogdan Chadkin
be458216a4 Drop all unused jsapi methods and fields 2022-10-02 09:55:08 +03:00
Bogdan Chadkin
783583538f Drop legacy JSAPI style handler 2022-10-02 00:24:43 +03:00
Bogdan Chadkin
bb590b8928 Drop extendDefaultPlugins 2022-10-02 00:17:16 +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
b0d19ebd1b Update snapshot format 2022-10-01 16:27:41 +03:00
Liam Mitchell
1b88baa123 More helpful preset warnings (#1645)
* More helpful preset warnings

* Optimise
2022-02-07 12:22:14 +03:00
Bogdan Chadkin
dfc5b982c9 Rename master branch to main 2021-12-25 15:09:34 +03:00
Kris Kowal
3a1c509b74 Fix extra newline at end of -o - output (#1237) 2021-12-23 14:16:48 +03:00