Skip to content

Commit f973ab7

Browse files
fix(nuxt): bind attrs to <img> inside <picture> if used
1 parent 84fd518 commit f973ab7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/nuxt/src/runtime/components/UnLazyImage.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
<script setup lang="ts">
1+
<script lang="ts">
22
import { createPlaceholderFromHash, lazyLoad } from 'unlazy'
33
import type { ImgHTMLAttributes } from 'vue'
4-
import { computed, onBeforeUnmount, ref, useRuntimeConfig, watchEffect } from '#imports'
4+
import { computed, defineComponent, onBeforeUnmount, ref, useRuntimeConfig, watchEffect } from '#imports'
55
6+
export default defineComponent({
7+
inheritAttrs: false,
8+
})
9+
</script>
10+
11+
<script setup lang="ts">
612
const props = withDefaults(
713
defineProps<{
814
/** Image source URL to be lazy-loaded. */
@@ -114,6 +120,7 @@ onBeforeUnmount(() => {
114120
>
115121
<img
116122
ref="target"
123+
v-bind="$attrs"
117124
:src="pngPlaceholder || placeholderSrc"
118125
:data-src="src"
119126
:data-srcset="srcSet"
@@ -124,6 +131,7 @@ onBeforeUnmount(() => {
124131
<img
125132
v-else
126133
ref="target"
134+
v-bind="$attrs"
127135
:src="pngPlaceholder || placeholderSrc"
128136
:data-src="src"
129137
:data-srcset="srcSet"

0 commit comments

Comments
 (0)