Skip to content

Commit

Permalink
perf(core): simplify attrNameFromPropName
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Aug 9, 2023
1 parent 546ec3c commit 9238cb7
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions core/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@ export function attrValueFromDataValue(value) {
* @return {string}
*/
export function attrNameFromPropName(name) {
const attrNameWords = name.split(/([A-Z])/);
if (attrNameWords.length === 1) return name;
return attrNameWords.reduce((prev, curr) => {
if (prev == null) return curr;
if (curr.length === 1 && curr.toUpperCase() === curr) {
return `${prev}-${curr.toLowerCase()}`;
}
return prev + curr;
});
// eslint-disable-next-line unicorn/prefer-string-replace-all
return name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
}

export const CHROME_VERSION = Number.parseFloat(navigator.userAgent.match(/Chrome\/([\d.]+)/)?.[1]);
Expand Down

0 comments on commit 9238cb7

Please sign in to comment.