Skip to content

Remove default density: 1 from fallback images, improve duplicate validation#1

Merged
nfriedly merged 1 commit intostrictfrom
fallback
May 11, 2021
Merged

Remove default density: 1 from fallback images, improve duplicate validation#1
nfriedly merged 1 commit intostrictfrom
fallback

Conversation

@nfriedly
Copy link
Owner

This makes two significant changes:

  • When parsing srcset="foo.jpg", the result no longer includes the 1x density:
    - { url: "foo.jpg", density: 1 }
    + { url: "foo.jpg" }
  • The validation checker now uses normalized values when checking for duplicates. It now recognizes that "foo.jpg 1x, bar.jpg" is invalid, as well as "foo.jpg 2x, bar.jpg 2.0x" because both contain two images with effectively duplicate descriptors.

@sindresorhus I had initially suggested putting this into a separate PR, but the more I think about it, the more I think it should just be included with sindresorhus#13. So, this PR targets the nfriedly:strict, meaning that if I merge it, then these changes will become part of that Pull Request. What do you think?

Either way, I think it makes sense to publish both sets of changes as a group.

also improve duplicate detection to disallow 1x + fallback and things like 2.0x + 2x
@sindresorhus
Copy link

Sounds ok to me 👍

@nfriedly nfriedly merged commit 42ec0db into strict May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants