mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-05-18 09:34:43 +02:00
fix aria-hidden="true" in @lucide/svelte (#4234)
This commit is contained in:
@@ -36,8 +36,6 @@ const iconNode: IconNode = ${JSON.stringify(children)};
|
||||
*/
|
||||
</script>
|
||||
|
||||
<Icon name="${iconName}" {...props} iconNode={iconNode}>
|
||||
{@render props.children?.()}
|
||||
</Icon>
|
||||
<Icon name="${iconName}" {...props} iconNode={iconNode} />
|
||||
`;
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
exports[`Using lucide icon components > should add a class to the element 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide-icon lucide lucide-smile my-icon"
|
||||
fill="none"
|
||||
height="24"
|
||||
@@ -51,14 +52,13 @@ exports[`Using lucide icon components > should add a class to the element 1`] =
|
||||
|
||||
<!---->
|
||||
<!---->
|
||||
|
||||
<!---->
|
||||
</svg>
|
||||
`;
|
||||
|
||||
exports[`Using lucide icon components > should adjust the size, stroke color and stroke width 1`] = `
|
||||
<div>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide-icon lucide lucide-smile"
|
||||
fill="none"
|
||||
height="48"
|
||||
@@ -108,8 +108,6 @@ exports[`Using lucide icon components > should adjust the size, stroke color and
|
||||
|
||||
<!---->
|
||||
<!---->
|
||||
|
||||
<!---->
|
||||
</svg>
|
||||
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
<circle cx="12"
|
||||
@@ -153,6 +152,7 @@ exports[`Using lucide icon components > should not scale the strokeWidth when ab
|
||||
exports[`Using lucide icon components > should render an component 1`] = `
|
||||
<div>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="lucide-icon lucide lucide-smile"
|
||||
fill="none"
|
||||
height="24"
|
||||
@@ -202,8 +202,6 @@ exports[`Using lucide icon components > should render an component 1`] = `
|
||||
|
||||
<!---->
|
||||
<!---->
|
||||
|
||||
<!---->
|
||||
</svg>
|
||||
|
||||
|
||||
@@ -260,12 +258,10 @@ exports[`Using lucide icon components > should render an icon slot 1`] = `
|
||||
|
||||
</line>
|
||||
|
||||
<!---->
|
||||
<!---->
|
||||
<text>
|
||||
Test
|
||||
</text>
|
||||
|
||||
<!---->
|
||||
</svg>
|
||||
|
||||
|
||||
@@ -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 <title> element', async () => {
|
||||
const { container } = render(TestSlots);
|
||||
|
||||
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user