Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(buildSrcSet): ensure largest size can't be repeated
The largest size was being repeated in certain conditions, since the value stored in `prev` was exact (possibly fractional) while the number saved in the list of resolutions is rounded to an even number, but the value stored in `prev` was the one being compared to `maxWidth`. In this fix we remove the code which pushes `maxWidth` to the list *after* the loop finishes and compare the last value in the list to `maxWidth` rather than the running exact fractional width value. These together eliminate the areas where the bug can subtly appear. It is then necessary to refactor the loop, by initializing the list to already contain the `minWidth` and then exiting early if `maxWidth` is equal (which has the side benefit that the cache won't be polluted with trivial cases) and then in the loop body push the *new* rather than previous value to the list, after rounding and clamping.
- Loading branch information