Skip to content

Commit

Permalink
feat(componets): introduce no-script prop
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 2, 2020
1 parent 75dba09 commit eb522b7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docs/content/en/nuxt-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ As you may notice providers and presets has a different in their usage, and it i
</code-block>
</code-group>

## `no-script`
Genererate `<noscript>` tag for browsers that aren’t running javascript.

## `legacy`

Using `nuxt-image` you should provider `width` and `height` for the component. These values are used to optimize image size and prevent [Cumulative Layout Shift](https://web.dev/cls/). But there are situation that we don't want to specify with and height for image. In this situations you can use `legacy` prop.
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/nuxt-image-mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default {
type: Object,
default: () => ({})
},
noScript: {
type: Boolean,
default: false
},
// `<img>` attrubutes
alt: {
type: String,
Expand Down
9 changes: 6 additions & 3 deletions src/runtime/nuxt-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ export default {
}
})

const noScript = h('noscript', {
domProps: { innerHTML: imageHTML(this) }
}, [])
let noScript = null
if (this.noScript) {
noScript = h('noscript', {
domProps: { innerHTML: imageHTML(this) }
}, [])
}

const placeholder = h('div', {
class: '__nim_pl',
Expand Down
9 changes: 6 additions & 3 deletions src/runtime/nuxt-picture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ export default {
originalImage
])

const noScript = h('noscript', {
domProps: { innerHTML: pictureHTML(this) }
}, [])
let noScript = null
if (this.noScript) {
noScript = h('noscript', {
domProps: { innerHTML: pictureHTML(this) }
}, [])
}

const placeholder = h('div', {
class: '__nim_pl',
Expand Down

0 comments on commit eb522b7

Please sign in to comment.