svg-sprite / svg-sprite

SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)

Home Page:https://github.com/svg-sprite/svg-sprite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CLI ignores `--svg-namespace-ids false`

michaelbragg opened this issue · comments

Overview:

Upgrading from 2.0.1 to 2.0.2 has broken the --svg-namespace-ids false command when using the CLI.

Our SVG Sprite builds, with 2.0.2, have started to include the full path as a namespace in the sprite file. Whereas 2.0.1 only included the filename as the ID.

On the command-line run svg-sprite -s --symbol-dest /assets/svg --svg-namespace-classnames false --svg-namespace-ids false --symbol-sprite icons.svg /assets/svg/icons/*.svg.

Original icon./assets/svg/icons/search.svg

<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M23.6719 20.7516L18.9984 16.0781C18.7875 15.8672 18.5016 15.75 18.2016 15.75H17.4375C18.7312 14.0953 19.5 12.0141 19.5 9.75C19.5 4.36406 15.1359 0 9.75 0C4.36406 0 0 4.36406 0 9.75C0 15.1359 4.36406 19.5 9.75 19.5C12.0141 19.5 14.0953 18.7313 15.75 17.4375V18.2016C15.75 18.5016 15.8672 18.7875 16.0781 18.9984L20.7516 23.6719C21.1922 24.1125 21.9047 24.1125 22.3406 23.6719L23.6672 22.3453C24.1078 21.9047 24.1078 21.1922 23.6719 20.7516ZM9.75 15.75C6.43594 15.75 3.75 13.0688 3.75 9.75C3.75 6.43594 6.43125 3.75 9.75 3.75C13.0641 3.75 15.75 6.43125 15.75 9.75C15.75 13.0641 13.0687 15.75 9.75 15.75Z"/>
</svg>

Expected Id value, as of 2.0.1, id="search":

<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol viewBox="0 0 24 24" id="search" xmlns="http://www.w3.org/2000/svg"><path d="m23.672 20.752-4.674-4.674a1.124 1.124 0 0 0-.796-.328h-.765a9.703 9.703 0 0 0 2.063-6A9.749 9.749 0 0 0 9.75 0 9.749 9.749 0 0 0 0 9.75a9.749 9.749 0 0 0 9.75 9.75 9.702 9.702 0 0 0 6-2.063v.765c0 .3.117.585.328.796l4.674 4.674c.44.44 1.153.44 1.589 0l1.326-1.327c.44-.44.44-1.153.005-1.593ZM9.75 15.75c-3.314 0-6-2.681-6-6 0-3.314 2.681-6 6-6 3.314 0 6 2.681 6 6 0 3.314-2.681 6-6 6Z"/></symbol></svg>

Actual Id value, as of 2.0.2, id="public--app--themes--demo--assets--svg--icons--search":

<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol viewBox="0 0 24 24" id="public--app--themes--demo--assets--svg--icons--search" xmlns="http://www.w3.org/2000/svg"><path d="m23.672 20.752-4.674-4.674a1.124 1.124 0 0 0-.796-.328h-.765a9.703 9.703 0 0 0 2.063-6A9.749 9.749 0 0 0 9.75 0 9.749 9.749 0 0 0 0 9.75a9.749 9.749 0 0 0 9.75 9.75 9.702 9.702 0 0 0 6-2.063v.765c0 .3.117.585.328.796l4.674 4.674c.44.44 1.153.44 1.589 0l1.326-1.327c.44-.44.44-1.153.005-1.593ZM9.75 15.75c-3.314 0-6-2.681-6-6 0-3.314 2.681-6 6-6 3.314 0 6 2.681 6 6 0 3.314-2.681 6-6 6Z"/></symbol></svg>

Resolving the issue can be achieved by rolling back SVG-Sprite to v2.0.1

Unsure how to proceed here because the changes in v2.0.2 were meant to fix another issue. Feel free to submit a PR with a test case.

@Kreeg it seems this is also a regression, unsure how ti fix it. If you have any ideas let me know.

commented

I'll take a look in next week

commented

That's strange, I can't confirm this on the latest version
svg-sprite.js -l info ~/projects/svg-sprite/test/fixture/svg/css/*.svg --css --svg-namespace-classnames false --svg-namespace-ids false --symbol-sprite icons.svg just did OK, with no full path included

commented

I can't confirm this in 2.0.2. Ids are fine

svg-sprite -s ~/projects/svg-sprite/test/fixture/svg/css/*.svg --svg-namespace-classnames false --svg-namespace-ids false --symbol-sprite icons.svg -l info

2.0.1 is the same.
@XhmikosR can you confirm this bug?

Can confirm I'm getting the same result as @michaelbragg.

I'm using 2.0.2, and this command:

"svg-test": "svg-sprite -s ./public/app/themes/theme/assets/svg/icons/*.svg --svg-namespace-classnames false --svg-namespace-ids false --symbol-sprite icons.svg --symbol-dest ./public/app/themes/theme/assets/svg",

It then outputs this:

<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol viewBox="0 0 55 40" id="public--app--themes--theme--assets--svg--icons--aeo" xmlns="http://www.w3.org/2000/svg"><path d="M32.909 17.594a12.534...

Whereas if using 2.0.1, it outputs this, which is the desired behaviour:

<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><symbol viewBox="0 0 55 40" id="aeo" xmlns="http://www.w3.org/2000/svg"><path d="M32.909 17.594a12.534...