Skip to content
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

Image sizes attribute is corrupted #7862

Closed
AndrewKvalheim opened this issue Mar 24, 2022 · 2 comments
Closed

Image sizes attribute is corrupted #7862

AndrewKvalheim opened this issue Mar 24, 2022 · 2 comments
Labels
✖️ Non-Parcel bug Bugs related to dependencies or plugins

Comments

@AndrewKvalheim
Copy link
Contributor

🐛 bug report

Some sizes attributes are corrupted.

🎛 Configuration and 💻 Code Sample

Minimal reproduction:

$ yarn add --dev parcel@2.4.0
$ echo '<img sizes="(min-width: 300px) 200px, 100px">' > index.html
$ parcel build index.html
$ cat dist/index.html

🤔 Expected Behavior

Expected output:

<img sizes="(min-width: 300px) 200px, 100px">

i.e. “on viewports at least 300px wide, use the 200px source, otherwise use the 100px source”

😯 Current Behavior

Actual output:

<img sizes="(min-width: 100px 200px, 300px)">

i.e. “nonsense; fall back to the 100vw source”

💁 Possible Solution

Not sure; I searched Parcel’s codebase for sizes but don’t see where it’s manipulating this value.

🔦 Context

This causes the browser to download the incorrect image source, resulting in either excess data usage (if the display size is narrower than 100vw) or blurry images (if the display size is wider than 100vw).

🌍 Your Environment

Software Version(s)
Parcel 2.4.0, 2.3.2, 2.2.1, 2.0.1
Node 16.14.2
Yarn 1.22.17
Operating System NixOS 21.11
@mischnic
Copy link
Member

mischnic commented Apr 1, 2022

This is caused by htmlnano: posthtml/htmlnano#180

As a workaround, you can add a .htmlnanorc with

{
    "sortAttributesWithLists": false
}

@mischnic mischnic added the ✖️ Non-Parcel bug Bugs related to dependencies or plugins label Apr 1, 2022
@mischnic mischnic closed this as completed Apr 2, 2022
@AndrewKvalheim
Copy link
Contributor Author

Ah of course, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✖️ Non-Parcel bug Bugs related to dependencies or plugins
Projects
None yet
Development

No branches or pull requests

2 participants