Skip to content

Commit 6c5b7eb

Browse files
committed
fix(svelte): prevent double onClick attribute on Svelte Link
fixes #222
1 parent db621ab commit 6c5b7eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/build-svelte-types.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const addOnClick = [
7272
'ActionsButton',
7373
];
7474

75-
const addOnClickProp = (componentName) => {
75+
const addOnClickProp = (componentName, content) => {
76+
if (content.includes(' onClick?: ')) return '';
7677
if (addOnClick.includes(componentName))
7778
return `\n onClick?: (e: any) => void;\n`;
7879
return '';
@@ -98,7 +99,8 @@ const createComponentTypes = (componentName, propsContent) => {
9899
.replace(
99100
'interface Props {',
100101
`export interface Props {\n class?: string;${addOnClickProp(
101-
componentName
102+
componentName,
103+
propsContent
102104
)}`
103105
)
104106
.replace(/ClassName/g, 'Class')

0 commit comments

Comments
 (0)