Skip to content

Commit

Permalink
fix: preserve event attribute casing in svelte 5 (#2347)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjones315 authored Apr 25, 2024
1 parent 957b8d6 commit d9e8948
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export function convertHtmlxToJsx(
node as Attribute,
parent,
options.preserveAttributeCase,
options.svelte5Plus,
element
);
break;
Expand All @@ -189,7 +190,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 d9e8948

Please sign in to comment.