Skip to content

Commit 46939f1

Browse files
committed
fix(nuxt-picture): render svgs with src not srcset
1 parent b3a9089 commit 46939f1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/runtime/components/nuxt-picture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default defineComponent({
3636
type Source = { srcset: string, src?: string, type?: string, sizes?: string }
3737
const sources = computed<Source[]>(() => {
3838
if (format.value === 'svg') {
39-
return [<Source>{ srcset: props.src }]
39+
return [<Source>{ src: props.src }]
4040
}
4141

4242
const formats = legacyFormat.value !== format.value

test/unit/picture.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,13 @@ describe('Renders simple image', () => {
8080
const sizes = wrapper.find('source').element.getAttribute('sizes')
8181
expect(sizes).toBe('(max-width: 500px) 500px, 900px')
8282
})
83+
84+
it('renders src when svg is passed', () => {
85+
const wrapper = mount(NuxtPicture, {
86+
propsData: {
87+
src: '/image.svg'
88+
}
89+
})
90+
expect(wrapper.html()).toMatchInlineSnapshot('"<picture><img data-nuxt-pic=\\"\\" src=\\"/image.svg\\"></picture>"')
91+
})
8392
})

0 commit comments

Comments
 (0)