Skip to content

Commit

Permalink
Merge branch 'main' of github.com:nuxt/image into main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 11, 2023
2 parents 60b96ae + 7e1eea1 commit 2506a71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/runtime/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function getSizes (ctx: ImageCTX, input: string, opts: ImageSizesOptions): Image
const sizeVariants = []
const srcsetVariants = []

if (Object.keys(sizes).length > 1) {
if (Object.keys(sizes).length >= 1) {
// 'sizes path'
for (const key in sizes) {
const variant = getSizesVariant(key, String(sizes[key]), height, hwRatio, ctx)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Renders simple image', () => {
height: 400,
sizes: '150'
})
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_300x400/image.png\\" width=\\"300\\" height=\\"400\\" data-nuxt-img=\\"\\" srcset=\\"/_ipx/s_150x200/image.png 1x, /_ipx/s_300x400/image.png 2x\\">"')
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_300x400/image.png\\" width=\\"300\\" height=\\"400\\" data-nuxt-img=\\"\\" sizes=\\"150px\\" srcset=\\"/_ipx/s_150x200/image.png 150w, /_ipx/s_300x400/image.png 300w\\">"')
})

it('with single sizes entry (responsive)', () => {
Expand All @@ -102,7 +102,7 @@ describe('Renders simple image', () => {
height: 400,
sizes: 'sm:150'
})
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_300x400/image.png\\" width=\\"300\\" height=\\"400\\" data-nuxt-img=\\"\\" srcset=\\"/_ipx/s_150x200/image.png 1x, /_ipx/s_300x400/image.png 2x\\">"')
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_300x400/image.png\\" width=\\"300\\" height=\\"400\\" data-nuxt-img=\\"\\" sizes=\\"150px\\" srcset=\\"/_ipx/s_150x200/image.png 150w, /_ipx/s_300x400/image.png 300w\\">"')
})

it('de-duplicates sizes & srcset', () => {
Expand Down

0 comments on commit 2506a71

Please sign in to comment.