diff --git a/packages/svelte/scripts/exportTemplate.mts b/packages/svelte/scripts/exportTemplate.mts index 7aaa73b22..0a3734bd1 100644 --- a/packages/svelte/scripts/exportTemplate.mts +++ b/packages/svelte/scripts/exportTemplate.mts @@ -36,8 +36,6 @@ const iconNode: IconNode = ${JSON.stringify(children)}; */ - - {@render props.children?.()} - + `; }); diff --git a/packages/svelte/tests/__snapshots__/lucide-svelte.spec.ts.snap b/packages/svelte/tests/__snapshots__/lucide-svelte.spec.ts.snap index 2c207dffa..f7af7b2bb 100644 --- a/packages/svelte/tests/__snapshots__/lucide-svelte.spec.ts.snap +++ b/packages/svelte/tests/__snapshots__/lucide-svelte.spec.ts.snap @@ -2,6 +2,7 @@ exports[`Using lucide icon components > should add a class to the element 1`] = ` `; exports[`Using lucide icon components > should adjust the size, stroke color and stroke width 1`] = `
@@ -126,6 +124,7 @@ exports[`Using lucide icon components > should not scale the strokeWidth when ab stroke-width="1" stroke-linecap="round" stroke-linejoin="round" + aria-hidden="true" class="lucide-icon lucide lucide-smile" > should not scale the strokeWidth when ab exports[`Using lucide icon components > should render an component 1`] = `
@@ -260,12 +258,10 @@ exports[`Using lucide icon components > should render an icon slot 1`] = ` - Test - diff --git a/packages/svelte/tests/lucide-svelte.spec.ts b/packages/svelte/tests/lucide-svelte.spec.ts index 47f4c5be1..ec0cb6604 100644 --- a/packages/svelte/tests/lucide-svelte.spec.ts +++ b/packages/svelte/tests/lucide-svelte.spec.ts @@ -94,3 +94,23 @@ describe('Using lucide icon components', () => { expect(IconComponent).toHaveAttribute('stroke-width', '1'); }); }); + +describe('Icon Component Accessibility', () => { + it('should have aria-hidden prop when no aria prop or children are present', async () => { + const { container } = render(Smile, { + props: { + size: 48, + color: 'red', + absoluteStrokeWidth: true, + }, + }); + + expect(container.firstChild).toHaveAttribute('aria-hidden', 'true'); + }); + + it('should not have aria-hidden prop when there are children that could be a element', async () => { + const { container } = render(TestSlots); + + expect(container.firstChild).not.toHaveAttribute('aria-hidden'); + }); +});