prismicio / prismic-vue

Vue plugin, components, and composables to fetch and present Prismic content
https://prismic.io/docs/technologies/vuejs
Apache License 2.0
65 stars 16 forks source link

Improve Image component accessibility #55

Closed VincentHardouin closed 2 years ago

VincentHardouin commented 2 years ago

Hello !

I have a problem with alt attribute in Image component.

When alt is not provided in Prismic, API returns null and alt attribute is not set. Otherwise, this attribute is very important for accessibility even if empty.

When I look at the component, I see two options :

The first one

It consists in inverting assign like this :

return h(
            'img',
            Object.assign(data, {
                attrs: {
                    src: url,
                    alt,
                    copyright
                    ...data.attrs,
                }
            })
    );

This allows overriding all fields from Prismic.

The second one

It consists in handling alt field.

return h(
            'img',
            Object.assign(data, {
                attrs: {
                    src: url,
                    alt: alt || '',
                    copyright
                    ...data.attrs,
                }
            })
    );

I can develop whichever suits you.

lihbr commented 2 years ago

Hey there, awesome catch! I'll deal with that this week on the Vue 2 & Vue 3 version following the 2nd strategy you described (accessibility by default) ☺️

lihbr commented 2 years ago

Released as part of:

Thanks for the heads up! Let us know if you encounter any more undesired behavior~ πŸš€

VincentHardouin commented 2 years ago

Thanks for your speed ! πŸš€