Skip to content

Commit 0b4db73

Browse files
committed
disable snake_case to camelCase
1 parent 7bda5f2 commit 0b4db73

File tree

1 file changed

+1
-32
lines changed
  • src/js/packages/@reactpy/client/src

1 file changed

+1
-32
lines changed

src/js/packages/@reactpy/client/src/vdom.tsx

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ export function createAttributes(
152152
createEventHandler(client, name, handler),
153153
),
154154
),
155-
// Convert snake_case to camelCase names
156-
}).map(normalizeAttribute),
155+
}),
157156
);
158157
}
159158

@@ -182,33 +181,3 @@ function createEventHandler(
182181
},
183182
];
184183
}
185-
186-
function normalizeAttribute([key, value]: [string, any]): [string, any] {
187-
let normKey = key;
188-
let normValue = value;
189-
190-
if (key === "style" && typeof value === "object") {
191-
normValue = Object.fromEntries(
192-
Object.entries(value).map(([k, v]) => [snakeToCamel(k), v]),
193-
);
194-
} else if (
195-
key.startsWith("data_") ||
196-
key.startsWith("aria_") ||
197-
DASHED_HTML_ATTRS.includes(key)
198-
) {
199-
normKey = key.split("_").join("-");
200-
} else {
201-
normKey = snakeToCamel(key);
202-
}
203-
return [normKey, normValue];
204-
}
205-
206-
function snakeToCamel(str: string): string {
207-
return str.replace(/([_][a-z])/g, (group) =>
208-
group.toUpperCase().replace("_", ""),
209-
);
210-
}
211-
212-
// see list of HTML attributes with dashes in them:
213-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#attribute_list
214-
const DASHED_HTML_ATTRS = ["accept_charset", "http_equiv"];

0 commit comments

Comments
 (0)