Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Preserve event attribute casing in svelte 5 #2347

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading