1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00
Commit Graph

1243 Commits

Author SHA1 Message Date
eb934b40f6 Serve svg for regressions and cache w3c test suite 2021-03-23 00:29:29 +03:00
7389bcddbf Override default floatPrecision with global
Ref https://github.com/svg/svgo/issues/1426

Previously extendDefaultPlugins incorrectly overrided global
floatPrecision.
2021-03-22 19:36:05 +03:00
d08815c1cd Implement simple node clone (#1450)
https://github.com/svg/svgo/pull/1279 faced some problems with node cloning.
In this diff I moved class/style live objects to JSAPI and made it non
enumerable to avoid deep cloning issues.

class list and style declaration classes are not longer need own clone
methods.
2021-03-22 18:55:08 +03:00
3d4adb6b04 Simplify number rendering and fix -0 in path
Ref https://github.com/svg/svgo/issues/1422
2021-03-22 14:38:06 +03:00
316a002299 Remove hasAttr and hasAttrLocal usages (#1447)
In most cases simple check for null is enough.
2021-03-22 01:24:59 +03:00
447f82ca6b Convert addAttributesToSVGElement to item plugin (#1448)
"full" plugins prevents from possible optimisation. We need to migrate
all plugins to "perItem" type and later implement visitor plugin api to
allow state.
2021-03-22 01:24:41 +03:00
13a0ad056b Specify --ignore-path for ESLint (#1443)
Otherwise, all files are included
2021-03-21 17:57:55 +03:00
e8d563c1f0 Fix invalid radix in cli (#1446) 2021-03-21 17:32:38 +03:00
bc5c4ea29c Add a test for removeXMLNS plugin (#1444) 2021-03-21 17:30:36 +03:00
3390df1186 removeOffCanvasPaths: Add one more test (#1445) 2021-03-21 13:30:20 +03:00
de0572c799 Update devDependencies (#1442)
* @types/mocha   ^8.2.1  →   ^8.2.2
* chai           ^4.3.0  →   ^4.3.4
* eslint        ^7.20.0  →  ^7.22.0
* mocha          ^8.3.0  →   ^8.3.2
* playwright     ^1.8.1  →   ^1.9.2
* rollup        ^2.39.0  →  ^2.42.1
* typescript     ^4.2.2  →   ^4.2.3
2021-03-21 10:30:09 +03:00
f44612e7a2 addClassesToSVGElement: add one more test (#1441) 2021-03-21 10:26:57 +03:00
65c733a42a Use charAt instead of charCodeAt when possible (#1440) 2021-03-20 21:50:06 +03:00
21d24006fd Remove the executable flag from files. (#1439) 2021-03-20 20:46:26 +03:00
b903de9554 test/config/_index.js: fix find usage (#1438) 2021-03-20 19:51:33 +03:00
e4ce31a287 Add fix script 2021-03-19 15:29:24 +03:00
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
6f2f62c5ee Access attributes directly (#1433)
Got rid from `.attrs`, `.attr()` and `.addAttr()` usages
2021-03-18 18:53:20 +03:00
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
8098ab7fb6 Replace attributes iterators with for/of (#1431)
These iterators allows to directly manipulate passed value
which does not let us to get rid from legacy "attrs" field.

Object.entries makes it easier to get an access to both attribute
name and value.
2021-03-17 12:50:16 +03:00
45d2b68a32 Move attrs polyfill into jsapi 2021-03-16 20:39:58 +03:00
604a9c5cdb Merge pull request #1428 from svg/refactor_apply_transforms
Refactor apply transforms
2021-03-16 01:31:26 +03:00
c925e4da0a Fix ts 2021-03-15 21:34:36 +03:00
61657433e1 Refactor apply transforms
- handle each command separately
- handle both relative and absolute commands
- moved into _applyTransforms.js to convert eventually into plugin
- apply transforms before converting into relative

These changes makes code independent and easy to work with.
2021-03-15 21:24:23 +03:00
c6254eb45d Merge pull request #1427 from svg/refactor-convert-to-relative
Refactor convertToRelative
2021-03-15 16:07:34 +03:00
92053c7ed8 Remove broken optimisation 2021-03-15 15:07:28 +03:00
a04b27a1df Refactor convertToRelative
Slight code simplification. Each command is processed exclusively
without assumtions. Removed moveto and closepath common coords
reference, handle in applyTransform instead. Rely on new path data
naming.
2021-03-15 13:41:12 +03:00
d27961745a Merge pull request #1420 from svg/xast-children
Convert element children to xast
2021-03-11 13:28:47 +03:00
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
b9a682443c Merge pull request #1419 from svg/xast-attributes
Convert attributes to xast with proxy fallback
2021-03-11 12:28:27 +03:00
bc87eea85e Fix lint 2021-03-10 23:15:29 +03:00
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
cdcd265fb7 Merge pull request #1418 from svg/xast-element
Prepare root and element nodes for xast
2021-03-10 23:10:42 +03:00
685d9fa55e Fix lint 2021-03-10 18:51:50 +03:00
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
54daf72d50 Merge pull request #1416 from svg/xast-text
Convert cdata and text nodes to xast
2021-03-10 18:49:12 +03:00
f369f24434 Merge pull request #1417 from omgovich/lighter-browser-bundle
Remove whitespaces and comments from the browser bundle
2021-03-10 18:42:09 +03:00
279962207e Remove whitespaces and comments from the browser bundle 2021-03-10 18:20:58 +03:00
73768cb65b Fix types 2021-03-10 17:36:36 +03:00
194058b9eb Clarify condition and add todo with new plugin 2021-03-10 16:22:37 +03:00
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
10ac712282 Convert to xast doctype, instruction and comment nodes (#1415)
Here we add [xast](https://github.com/syntax-tree/xast) support
to three basic nodes: doctype, instruction and comment

Some tests are rewritten instead of checking each field to `.include`
assertion which is able to match shape of object.
2021-03-10 15:39:49 +03:00
5161156418 Fix types 2021-03-10 14:22:38 +03:00
8622a5f31b Convert to xast doctype, instruction and comment nodes
Here we add [xast](https://github.com/syntax-tree/xast) support
to three basic nodes: doctype, instruction and comment

Some tests are rewritten instead of checking each field to `.include`
assertion which is able to match shape of object.
2021-03-10 14:10:40 +03:00
d1d6e5efe8 Remove prefix/local support in elements and attributes (#1413)
These parts of element and attribute name are easy to extract.
Now we can easily replace attrs with xast attributes object.
2021-03-10 13:26:15 +03:00
2458b70f31 Remove licenses 2021-03-09 23:40:36 +03:00
cfb7c28bf6 Lint unformatted code 2021-03-09 20:18:19 +03:00
00ec0f71fe Format all plugins with prettier 2021-03-09 19:58:00 +03:00
1be0d0dba1 2.2.2 v2.2.2 2021-03-09 12:51:15 +03:00
ddbd7046b2 Ignore keyframes in computeStyle
Ref https://github.com/svg/svgo/issues/1408
2021-03-09 01:47:56 +03:00