Skip to content

Commit

Permalink
Fixed props aliasing
Browse files Browse the repository at this point in the history
HTML elements require dataset props to be camelCased.
  • Loading branch information
felixgirault committed Oct 11, 2024
1 parent 51b4d35 commit 9e3af0d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/utils/updatePurposeElements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const backupName = (attribute: string) => `orejime-${attribute}`;
const backupName = (attribute: string) => {
const name = `orejime-${attribute}`;
const camelCased = name.replace(
/[-_](.)/g,
(_, char) => char.toUpperCase()
);

return camelCased;
}

const backupAttribute = <T extends HTMLElement>(element: T, name: string) => {
if (element.getAttribute(name) && !element.dataset?.[name]) {
Expand Down

0 comments on commit 9e3af0d

Please sign in to comment.