Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order: mergePaths should run before collapseGroups #290

Closed
wants to merge 1 commit into from
Closed

Order: mergePaths should run before collapseGroups #290

wants to merge 1 commit into from

Conversation

fregante
Copy link

An SVG like this one:

<g>
    <path fill="#AC162C" d="pathdata"/>
    <path fill="#AC162C" d="pathdata-2"/>
</g>

…will be compressed into:

<g fill="#AC162C">
    <path d="pathdata1+2"/>
</g>

… which, if svgoed again, will be optimized further:

<path d="pathdata1+2" fill="#AC162C"/>

This is due to collapseGroups running before mergePaths, therefore not catching the newly-unnecessary <g fill="#AC162C">

Test SVG file: http://cl.ly/Yw2Y

This:

<g>
	<path d="pathdata"/>
	<path d="pathdata-2"/>
</g>

will now be optimized into

<path d="pathdata1+2"/>

rather than

<g><path d="pathdata1+2"/></g>
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 81d7a08 on bfred-it:master into 259ae7e on svg:master.

@GreLI
Copy link
Member

GreLI commented Dec 12, 2014

There is a catch. Consider the example:

<g>
    <path fill="#AC162C" d="pathdata"/>
    <g>
        <path fill="#AC162C" d="pathdata-2"/>
    </g>
</g>

Right now it'll be transformed into

<g>
    <path fill="#AC162C" d="pathdata"/>
    <path fill="#AC162C" d="pathdata-2"/>
</g>

after colapseGroups and then merged with mergePath.
But it will not happen after your changes. A more generic solution is needed.
For now there is --multipass key to account such cases as yours.

@fregante fregante closed this Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants