popeindustries / inline-source

Tool for inlining flagged js, css, and img sources in html
MIT License
194 stars 44 forks source link

Remove alt attribute when inlining SVG images #56

Closed olajideoye closed 7 years ago

olajideoye commented 7 years ago

Inlining an SVG image tag containing an alt attribute works as expected: it generates an <svg> element containing the alt attribute (since attributes are preserved). The only problem is that alt attributes aren't allowed in SVG elements and throws and throws an error when validated with the W3C HTML Validator.

So inlining something like this

<img src="github.svg" alt="GitHub" inline>

generates this (as expected)

<svg width="40" height="40" viewBox="0 0 40 40" alt="GitHub">...</svg>

but fails the W3C HTML Validator: contents of text-input area - Nu Html Checker 2017-11-03 04-16-21.png

Please check here for a list of allowed attributes

olajideoye commented 7 years ago

I'll write a fix for this an create a pull request.