mrsum / webpack-svgstore-plugin

Simple svg-sprite creating with webpack
https://www.npmjs.com/package/webpack-svgstore-plugin
200 stars 90 forks source link

Fix missing text node content #47

Closed ianmstew closed 8 years ago

ianmstew commented 8 years ago

I noticed that when a source SVG has a <style>...</style> block, the final sprite only includes empty <style></style> tags (no text content). I tracked down the issue to the symbols-childs.jade mixin. If you approve, I would love to see this fix in a release shortly because I have chosen this webpack plugin for production use. :)

Note that I chose to always use CDATA XML escapes for text content due to a recommendation from the W3C for escaping embedded style sheets within SVG: https://www.w3.org/TR/SVG/styling.html#StyleElementExample. In my implementation, the CDATA escape will apply to ALL text nodes, not only those located within a style tag. I think this is safest, though, because the underlying DOM parser seems not to track whether CDATA escapes were used to escape the original text, and a stray angle bracket could throw off SVG parsing.

lgordey commented 8 years ago

Yes, that's right. This section was really lost.

Thank you @ianmstew !

ianmstew commented 8 years ago

Thank you for an excellent library! The svgo integration is perfect.

lgordey commented 8 years ago

Only because of such good pull requests! Try 2.1.2 version.

ianmstew commented 8 years ago

:+1: Works perfectly!