elrumordelaluz/path-that-svg

Preserve attributes

Closed this issue ยท 4 comments

Hello, thanks for this library, I was just about to write something similar ๐Ÿ‘
I'm having an issue where I would like my class attribute to be preserved:

<svg><line class="foo" x1="0" y1="0" x2="5" y2="5" /></svg>

becomes:

<svg><path d="M0 0 L5 5" /></svg>

The solution does not need to be limited to just the class attribute, I suppose any attribute that is not used by the conversion and does not collide with d should carry over.

hey @danmarshall you are absolutely right, thank you!

I did a very fast cleanup, instead I need to delete only those attributes not used by the new path element but used by its element before the conversion

Should work as expected in path-that-svg@1.2.1.
Please let me know if there's any related issue.

Thanks again,

Hi Lionel, it seems there is another issue: transform attributes are also dropped ๐Ÿ˜ฏ

<svg><path class="c1" d="M0,0 V1" transform="translate(9 9)" /></svg>

becomes

<svg><path class="c1" d="M0,0 V1"/></svg>

hey @danmarshall thank you again to report this.

Should be solved in v1.2.2.