Skip to content

Commit 71e01aa

Browse files
authored
feat(VImg): pass attributes to the underlying <img> (#22439)
resolves #18860 closes #18907
1 parent ecd07b9 commit 71e01aa

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • packages/vuetify/src/components/VImg

packages/vuetify/src/components/VImg/VImg.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from 'vue'
2929
import {
3030
convertToUnit,
31+
filterInputAttrs,
3132
genericComponent,
3233
getCurrentInstance,
3334
propsFactory,
@@ -105,6 +106,8 @@ export const VImg = genericComponent<VImgSlots>()({
105106

106107
directives: { vIntersect },
107108

109+
inheritAttrs: false,
110+
108111
props: makeVImgProps(),
109112

110113
emits: {
@@ -113,7 +116,7 @@ export const VImg = genericComponent<VImgSlots>()({
113116
error: (value: string | undefined) => true,
114117
},
115118

116-
setup (props, { emit, slots }) {
119+
setup (props, { attrs, emit, slots }) {
117120
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(() => props.color)
118121
const { roundedClasses } = useRounded(props)
119122
const vm = getCurrentInstance('VImg')
@@ -348,6 +351,8 @@ export const VImg = genericComponent<VImgSlots>()({
348351

349352
useRender(() => {
350353
const responsiveProps = VResponsive.filterProps(props)
354+
const [rootAttrs, imageAttrs] = filterInputAttrs(attrs)
355+
351356
return (
352357
<VResponsive
353358
class={[
@@ -366,6 +371,7 @@ export const VImg = genericComponent<VImgSlots>()({
366371
props.style,
367372
]}
368373
{ ...responsiveProps }
374+
{ ...rootAttrs }
369375
aspectRatio={ aspectRatio.value }
370376
aria-label={ props.alt }
371377
role={ props.alt ? 'img' : undefined }
@@ -376,7 +382,7 @@ export const VImg = genericComponent<VImgSlots>()({
376382
>{{
377383
additional: () => (
378384
<>
379-
<__image />
385+
<__image { ...imageAttrs } />
380386
<__preloadImage />
381387
<__gradient />
382388
<__placeholder />

0 commit comments

Comments
 (0)