Skip to content

Commit 2c99c58

Browse files
fix: builtin custom elements check when transforming attributes (#2824)
* Fix builtin custom elements check when transforming attributes * Fix lint issue
1 parent cda8113 commit 2c99c58

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function handleAttribute(
113113
if (
114114
!preserveCase &&
115115
!svgAttributes.find((x) => x == name) &&
116-
!(element instanceof Element && element.tagName.includes('-')) &&
116+
!(element instanceof Element && element.isCustomElement()) &&
117117
!(svelte5Plus && name.startsWith('on'))
118118
) {
119119
return name.toLowerCase();

packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Element.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ export class Element {
255255
}
256256
}
257257

258+
isCustomElement(): boolean {
259+
if (this.tagName.includes('-')) {
260+
return true;
261+
}
262+
if (
263+
this.node.attributes
264+
?.find((a: BaseNode) => a.name === 'is')
265+
?.value[0]?.data.includes('-')
266+
) {
267+
return true;
268+
}
269+
return false;
270+
}
271+
258272
private getStartTransformation(): TransformationArray {
259273
const createElement = `${this.typingsNamespace}.createElement`;
260274
const addActions = () => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ svelteHTML.createElement("div", { "is":`custom-element`,"camelCase":`true`,"kebab-case":`true`,"PascalCase":`true`,"snake_case":`true`,});}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div is="custom-element" camelCase="true" kebab-case="true" PascalCase="true" snake_case="true" />

0 commit comments

Comments
 (0)