Skip to content

Commit

Permalink
fix: do not render image without src
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Nov 10, 2020
1 parent 68863f9 commit cbeada1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
54 changes: 27 additions & 27 deletions src/runtime/nuxt-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,33 @@ export default {
})
}

const originalImage = h('img', {
class: '__nim_o',
style: {
position: 'absolute',
left: 0,
top: 0,
margin: 0,
width: '100%',
height: '100%',
objectFit: 'cover',
objectPosition: 'center center',
transition: 'opacity 800ms ease 0ms',
opacity: 0,
...(this.lazyState === LazyState.LOADED ? {
opacity: 1
} : {})
},
attrs: {
src: this.lazyState !== LazyState.IDLE ? this.generatedSrc : undefined,
srcset: this.lazyState !== LazyState.IDLE ? this.generatedSrcset : undefined,
sizes: this.lazyState !== LazyState.IDLE ? this.generatedSizes : undefined,
...this.imgAttributes
},
on: {
load: this.onImageLoaded
}
})
let originalImage = null
if (this.lazyState !== LazyState.IDLE) {
originalImage = h('img', {
class: '__nim_o',
style: {
position: 'absolute',
left: 0,
top: 0,
margin: 0,
width: '100%',
height: '100%',
objectFit: 'cover',
objectPosition: 'center center',
transition: 'opacity 800ms ease 0ms',
opacity: this.lazyState === LazyState.LOADED ? 1 : 0
},
attrs: {
src: this.generatedSrc,
srcset: this.generatedSrcset,
sizes: this.generatedSizes,
...this.imgAttributes
},
on: {
load: this.onImageLoaded
}
})
}

let noScript = null
if (this.noScript) {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/nuxt-picture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default {
})
}

const picture = h('picture', {}, [
const picture = this.lazyState === LazyState.IDLE ? null : h('picture', {}, [
...sources,
originalImage
])
Expand Down

0 comments on commit cbeada1

Please sign in to comment.