Skip to content

Commit

Permalink
Preserve event attribute casing in svelte 5
Browse files Browse the repository at this point in the history
  • Loading branch information
jaycejonestrinityonline committed Apr 24, 2024
1 parent 4c8c0db commit 5db3f87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/svelte2tsx/src/htmlxtojsx_v2/index.ts
Expand Up @@ -178,6 +178,7 @@ export function convertHtmlxToJsx(
node as Attribute,
parent,
options.preserveAttributeCase,
options.svelte5Plus,
element
);
break;
Expand All @@ -188,7 +189,14 @@ export function convertHtmlxToJsx(
handleEventHandler(str, node as BaseDirective, element);
break;
case 'Let':
handleLet(str, node, parent, options.preserveAttributeCase, element);
handleLet(
str,
node,
parent,
options.preserveAttributeCase,
options.svelte5Plus,
element
);
break;
case 'Text':
handleText(str, node as Text, parent);
Expand Down
4 changes: 3 additions & 1 deletion packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts
Expand Up @@ -55,6 +55,7 @@ export function handleAttribute(
attr: Attribute,
parent: BaseNode,
preserveCase: boolean,
svelte5Plus: boolean,
element: Element | InlineComponent
): void {
if (
Expand Down Expand Up @@ -112,7 +113,8 @@ export function handleAttribute(
if (
!preserveCase &&
!svgAttributes.find((x) => x == name) &&
!(element instanceof Element && element.tagName.includes('-'))
!(element instanceof Element && element.tagName.includes('-')) &&
!(svelte5Plus && name.startsWith('on'))
) {
return name.toLowerCase();
} else {
Expand Down
2 changes: 2 additions & 0 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Let.ts
Expand Up @@ -15,6 +15,7 @@ export function handleLet(
node: BaseNode,
parent: BaseNode,
preserveCase: boolean,
svelte5Plus: boolean,
element: Element | InlineComponent
): void {
if (element instanceof InlineComponent) {
Expand Down Expand Up @@ -47,6 +48,7 @@ export function handleLet(
},
parent,
preserveCase,
svelte5Plus,
element
);
}
Expand Down

0 comments on commit 5db3f87

Please sign in to comment.