Skip to content

Commit

Permalink
fix: reduce warnings about density values > 2
Browse files Browse the repository at this point in the history
resolves #1308
  • Loading branch information
danielroe committed Apr 22, 2024
1 parent 597c70b commit dad493a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/runtime/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ export function checkDensities(densities: number[]) {
throw new Error('`densities` must not be empty, configure to `1` to render regular size only (DPR 1.0)')
}
if (import.meta.dev && Array.from(densities).some(d => d > 2)) {
console.warn('[nuxt] [image] Density values above `2` are not recommended. See https://observablehq.com/@eeeps/visual-acuity-and-device-pixel-ratio.')
const _densities = densities as number[] & { _warned?: boolean }
if (!_densities._warned) {
console.warn('[nuxt] [image] Density values above `2` are not recommended. See https://observablehq.com/@eeeps/visual-acuity-and-device-pixel-ratio.')
}
_densities._warned = true
}
}

Expand Down

0 comments on commit dad493a

Please sign in to comment.