Skip to content

Commit d6e19b1

Browse files
committed
fix(toolbar): skip image audit for framework components
Images inside astro-island elements (React, Vue, Svelte, etc. with client:* directives) now skip the 'Use the Image component' audit warning, since these components can't directly use Astro's Image component. Fixes #15048
1 parent 353ebf1 commit d6e19b1

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Skips "Use the Image component" audit warning for images inside framework components (React, Vue, Svelte, etc.)

packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export const perf: AuditRuleWithSelector[] = [
1010
message: 'This image could be replaced with the Image component to improve performance.',
1111
selector: 'img:not([data-image-component])',
1212
async match(element) {
13+
// Skip images inside framework components (React, Vue, Svelte, etc.)
14+
// These are wrapped in astro-island and can't directly use Astro's Image component
15+
if (element.closest('astro-island')) return false;
16+
1317
const src = element.getAttribute('src');
1418
if (!src) return false;
1519

0 commit comments

Comments
 (0)