mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-05-18 08:45:08 +02:00
fix(vue): clone slots before passing to icon (#4339)
Co-authored-by: Axtho <th@ebtc.org>
This commit is contained in:
committed by
GitHub
parent
6d38f90429
commit
446e644e63
@@ -19,7 +19,7 @@ const createLucideIcon =
|
||||
iconNode,
|
||||
name: iconName,
|
||||
},
|
||||
slots,
|
||||
slots.default ? { default: slots.default } : undefined,
|
||||
);
|
||||
|
||||
export default createLucideIcon;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { render, fireEvent, cleanup } from '@testing-library/vue';
|
||||
import { Smile, Edit2, Pen } from '../src/lucide-vue';
|
||||
import createLucideIcon from '../src/createLucideIcon';
|
||||
import defaultAttributes from '../src/defaultAttributes';
|
||||
|
||||
describe('Using lucide icon components', () => {
|
||||
@@ -108,6 +109,25 @@ describe('Using lucide icon components', () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should handle non-extensible slots objects', () => {
|
||||
const Icon = createLucideIcon('test-icon', [['path', { d: 'M0 0h1', key: 'test-key' }]]);
|
||||
const slots = Object.freeze({
|
||||
default: () => 'Hello World',
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
Icon(
|
||||
{},
|
||||
{
|
||||
attrs: {},
|
||||
emit: vi.fn(),
|
||||
expose: vi.fn(),
|
||||
slots,
|
||||
},
|
||||
),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('should render the alias icon', () => {
|
||||
const { container } = render(Pen, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user