New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Parcel 2 SVG attributes are all getting lower cased #5004
Comments
It's actually not htmlnano (because it also happens with parcel/packages/transformers/html/src/HTMLTransformer.js Lines 20 to 22 in 46e8ffa
@wbinnssmith Any chance you remember why you added this? |
Apart from SVG, and possibly React custom attributes, this is generally a good choice. Even JS's Element.getAttribute() lowercases names before looking them up. Chrome also doesn't seem to care about lowercase attributes in SVG, but a) the minimiser does and b) transforming valid code into technically invalid code just seems like a bad idea. Is there a way to make this transformation be applied to everything except SVG? |
Although lowerCaseAttributeNames is forced to be true in the HTMLTransformer I'm still not convinced this is actually a Parcel issue. The fact that the htmlparser2 library converts svg attributes to lower case seems to be wrong behaviour. I've submitted an issue to that project here: fb55/htmlparser2#539 I propose no-one change this Parcel 2 behaviour until we hear back from the maintainer of the parser. If the fix is applied at that level then upgrading the libraries will be enough. |
Seems that htmlparser2 issue got closed. What would be the follow-up here? |
Per above this is caused by the use of |
I just tested and lower case attribute names seem to work for me in browsers. This makes sense as the HTML spec says
See https://html.spec.whatwg.org/multipage/syntax.html#syntax-attribute-name Can someone explain what kind of problems they've seen with this? |
SVGO is opinionated about attribute case and deletes |
Hmm interesting. I'm not sure what we should do about this. We can't simply remove that parser option because we need to handle attributes of any case for other parts of HTML. I think ideally SVGO would have an option to indicate that the SVG is embedded inside HTML, because this is completely valid - i.e. someone could author their HTML that way and SVGO would be broken. |
Maybe we should just disable |
That sounds reasonable; better to have some pending optimizations than corrupted images. |
🐛 bug report
Using Parcel 2 when I build, my inline SVG graphics get their attributes lowercased. SVG is a case sensitive specification, so this is not desired.
There are several other bug reports here about SVGO stripping out tags (like viewBox) which I believe is happening exactly because of this attribute lowercasing.
It feels like this is something that could be solved if I could get the correct configuration, but I've spent half a day on it and gotten nowhere... maybe someone here knows how to solve it?
(apart from this niggle I'm loving Parcel 2 so far)
🎛 Configuration
cli-command:
npx parcel build index.html
package.json
.posthtmlrc
.htmlnanorc
🤔 Expected Behavior
Attributes in the specification should not be changed to lower case.
😯 Current Behavior
The svg gets all its attribute names converted to lower case:
💻 Code Sample
index.html
🌍 Your Environment
The text was updated successfully, but these errors were encountered: