jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

Fix element classNames/ids for objects when using classIdPrefix property #79

Closed samshelley closed 7 years ago

samshelley commented 7 years ago

Hi @jhamlet, thanks for making this loader!

I'm taking advantage of the classIdPrefix property as I have multiple auto-generated svgs with conflicting class names being loaded into the same file and ran into an issue where the class styles are not showing up in my application. I think the issue is because the "." is included in both the style names and in the actual class property for the rendered element.

This PR seemed to fix the issue for me -- although not sure if this is actually the right way to go about fixing it. (it assumes the styles are calculated sequentially prior to the elements, but I think that's already assumed given the cache?) Let me know if there's a better way to do this.

I also updated the test to match the new output.

agonbina commented 7 years ago

I had the same issue as well and this fixes it. It would be great to merge it(if it doesn't break anything else), until then I'll use the fork from @samshelley.

Thanks.

jhamlet commented 7 years ago

Duoh! Dumb mistake on my part.

I'll rev a patch version in a day, or so.

jhamlet commented 7 years ago

Merged and published v0.4.5

samshelley commented 7 years ago

Awesome, thanks @jhamlet