const normalizeElementKeyMap: Map = new Map([ ['className', 'class'], ['htmlFor', 'for'], ['crossOrigin', 'crossorigin'], ['httpEquiv', 'http-equiv'], ['itemProp', 'itemprop'], ['fetchPriority', 'fetchpriority'], ['noModule', 'nomodule'], ['formAction', 'formaction'], ]) export const normalizeIntrinsicElementKey = (key: string): string => normalizeElementKeyMap.get(key) || key export const styleObjectForEach = ( style: Record, fn: (key: string, value: string | null) => void ): void => { for (const [k, v] of Object.entries(style)) { const key = k[0] === '-' || !/[A-Z]/.test(k) ? k // a CSS variable or a lowercase only property : k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`) // a camelCase property. convert to kebab-case fn( key, v == null ? null : typeof v === 'number' ? !key.match( /^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/ ) ? `${v}px` : `${v}` : v ) } }