Skip to content

Commit

Permalink
fix(svelte): prevent double onClick attribute on Svelte Link
Browse files Browse the repository at this point in the history
fixes #222
  • Loading branch information
nolimits4web committed Sep 18, 2024
1 parent db621ab commit 6c5b7eb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/build-svelte-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const addOnClick = [
'ActionsButton',
];

const addOnClickProp = (componentName) => {
const addOnClickProp = (componentName, content) => {
if (content.includes(' onClick?: ')) return '';
if (addOnClick.includes(componentName))
return `\n onClick?: (e: any) => void;\n`;
return '';
Expand All @@ -98,7 +99,8 @@ const createComponentTypes = (componentName, propsContent) => {
.replace(
'interface Props {',
`export interface Props {\n class?: string;${addOnClickProp(
componentName
componentName,
propsContent
)}`
)
.replace(/ClassName/g, 'Class')
Expand Down

0 comments on commit 6c5b7eb

Please sign in to comment.