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

634 Commits

Author SHA1 Message Date
Seth Falco
a3da8b3a76 refactor: use set in _collections (#1899) 2023-12-24 01:54:17 +00:00
Kendell R
a7859eb177 fix(convertPathData): fix some weird behavior (#1867) 2023-12-24 01:47:29 +00:00
Seth Falco
22533f1ffe chore: update prettier and eslint (#1885) 2023-12-15 13:10:21 +00:00
Jon Dufresne
40544220e8 chore: tidy up eslint config and usage (#1883) 2023-12-15 12:32:20 +00:00
Jon Dufresne
aa470c7952 chore: apply prettier to all supported file types (#1870) 2023-12-15 12:30:44 +00:00
Seth Falco
e6deecac90 fix: improve handling of url references in reference attributes (#1881) 2023-12-10 02:07:35 +00:00
Seth Falco
c172c9e6d6 fix(cleanupIds): handle uri encoded references (#1880) 2023-12-10 00:31:55 +00:00
john-neptune
6a814cd2e7 fix(prefixIds): update all nodes in style tags (#1736) 2023-12-09 23:04:45 +00:00
Kendell R
2d9e101ded fix(removeHiddenElems): handle defs better (#1879) 2023-12-09 22:25:30 +00:00
Seth Falco
8390add9ab feat(removeUnknownAndDefaults): apply to xml declarations (#1872) 2023-12-07 11:56:14 +00:00
Jon Dufresne
d6ff70baf9 chore: fix several typos (#1868) 2023-12-03 18:02:22 +00:00
Seth Falco
a663d8d683 fix(cleanupEnableBackground): clean up inline styles too (#1866) 2023-12-02 12:26:21 +00:00
Seth Falco
39e855be9e fix(inlineStyles): refactor how styles are collected (#1865) 2023-12-01 16:45:09 +00:00
Kendell R
51449360f5 fix(cleanupIds): properly handle begin regex to fix #1775 (#1862) 2023-11-30 14:38:27 +00:00
Vincent Bernat
f0ec586991 fix(removeEmptyContainers): don't remove empty containers if parent is switch (#1747) 2023-11-29 01:03:49 +00:00
Kendell R
8dd7a3b2fc fix(convertPathData): handle setting prev properly to fix path joining and #1855 (#1856) 2023-11-29 00:39:08 +00:00
Kendell R
86d5040382 fix(convertPathData): account for error in z conversions (#1842) 2023-11-28 02:01:20 +00:00
Sebastian Krah
4d15ef2be9 fix: use .d.ts file extension for type definitions (#1780) 2023-11-26 23:38:52 +00:00
Seth Falco
e22d533be8 fix(removeHiddenElems): remove hidden definitions usage (#1852) 2023-11-26 20:55:35 +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
9809b67852 fix(inlineStyles): dont remove id if traversed in another selector (#1836) 2023-11-14 19:01:39 +00:00
Seth Falco
b740c07695 fix(inlineStyles): dont remove wrapper class if traversed (#1832) 2023-11-13 14:53:30 +00:00
Seth Falco
7e25b62fa7 fix(inlineStyles): inline styles in order of priority (#1831) 2023-11-12 18:11:46 +00:00
Seth Falco
1f766ac509 fix(convertPathData): skip if transform overridden in styles (#1830) 2023-11-12 14:54:55 +00:00
Kendell R
14bdacc2df feat(convertPathData): replace with z and remove z when optimal (#1822) 2023-11-12 13:52:01 +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
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
07c09199ed fix: remove hrefs for unconventional namespaces (#1820) 2023-11-04 15:17:15 +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
e73ee2de96 fix(removeScriptElement): collapse a tag propertly (#1818) 2023-11-04 13:42:07 +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
a880505859 fix(removeScriptElement): remove link anchors with scripts (#1807) 2023-10-29 14:46:55 +00:00
Seth Falco
7de793c54a fix(removeComments): make preserving comments a param (#1812)
Converts the hard-coded exception to a param so users can override this
behavior to preserve custom patterns or drop the logic altogether.
2023-10-27 18:03:50 +01:00
Seth Falco
bf45a0225a fix(prefixIds): dynamic functions should produce same prefix for given id (#1814)
Reuse the same prefix if an ID is encountered multiple times.
2023-10-25 12:54:02 +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
Seth Falco
2539b9f4c6 fix(inlineStyles): remove all classes in multiclass selector (#1801)
When running into a multi-class selector with `inlineStyles`, it would
only remove the first class of the selector instead of all of them.

This iterates the classes in the selector instead of only taking the
first. Also performs some minor refactors.
2023-09-27 17:19:46 +01:00
Seth Falco
b15da27af4 fix(minifyStyles): pass empty arrays for usage (#1800) 2023-09-25 23:13:54 +01:00
Seth Falco
7e99c0bd49 fix(inlineStyles): case insensitive style props (#1797)
Style property names are case-insensitive, for example `fill`, `FILL`,
and `FiLl` are all valid but refer to the same property. So when
inlining styles, we compare the lowercase strings and only use the last
instance of the property rather than embed them all.
2023-09-25 19:05:11 +01:00
Seth Falco
42f7752db1 fix(cleanupIds): handle when 2 ids referenced in one attr (#1795) 2023-09-25 19:04:31 +01:00
Seth Falco
f07e9de089 fix: resolve regression test for removeHiddenElems (#1793) 2023-09-25 19:04:06 +01:00
Seth Falco
078a09c19a fix(reusePaths): pass test-regression task (#1791)
Signed-off-by: Seth Falco <seth@falco.fun>
2023-09-25 19:03:42 +01:00
Abe Fehr
437c09b006 Add support for image/jpeg mimetype (#1742)
In practice, this plugin does not work to remove embedded jpg images.

On further inspection, it's because the plugin is looking for
image/jpg, which I'm not even sure is a valid mimetype. Inkscape uses
image/jpeg as the mimetype for embedded JPG images.

Co-authored-by: Seth Falco <seth@falco.fun>
2023-09-24 13:32:13 +01:00
Seth Falco
bd750ceebb fix(reusePaths): dont reuse id if referenced in href (#1784)
Fixes a bug where the reusePaths plugin would reuse the node ID that
it's optimizing, but that ID was also referenced in a href elsewhere
in the document, so it unintentionally applied the path to other nodes.
2023-09-23 21:47:04 +01:00
Seth Falco
5f40d8bce4 fix(reusePaths): reuse defs tag if exists and remove redundant nodes (#1785) 2023-09-23 21:37:04 +01:00
Marvin Hagemeister
c641da2734 Speed up strongRound by avoiding string casting (#1716)
I'm currently profiling my build pipeline and noticed that the
`strongRound` function showed up a couple of times, followed immediately
with a bit of GC cleanup shortly after. We can speed up that function by
avoiding the string casting caused by `Number.prototype.toFixed()`.

In my project's build pipeline with lots of svg icons this saves about
1.4s in total.

<img width="792" alt="js-tools-strongRound"
src="https://user-images.githubusercontent.com/1062408/204393563-666be3e0-e0ee-4608-9b7d-9ea8352bd36b.png">
2022-11-30 11:53:39 +03:00
Bogdan Chadkin
2260aab8c1 Remove csso types from definitions 2022-11-18 11:56:38 +03:00