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.
Ref https://github.com/syntax-tree/xast
- added type: root | element
- renamed elem to name
- replaced "elem" property checks with check for correct type
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.
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.
Changed the TS config file to include all relevant folders and explicitly exclude those files that fail the type checks. In this way new files will be automatically type checked and we can see the list of files that need types improvements.
In this pass I also fixed some js files.
Visual regressions tests will give us more confidence in SVGO stability.
Test cases are downloaded from w3.org, screenshooted with playwright and
compared with pixelmatch.
Added Typescript support via JSDoc comments for some files.
The code has really outdated type signatures, so in order to fully type the codebase the changes need to be incremental.
To check the types run:
npx tsc
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.
Ref https://github.com/svg/svgo/issues/32
Added `stringifyPathData` utility to produce small as possible path by
- matching leading moveto and line to commands (m -> l, M -> L)
- combining moveto and lineto commands
- avoiding space before decimal numbers if possible