Skip to content

Commit

Permalink
fix(jsx): kebab case support for style
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Sep 11, 2021
1 parent 35f2a49 commit 6188a9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/jsx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { className, m, style, svg, VDelta, VElement, VFlags, VNode, VProps } from './index';
import { kebab } from './m';

type JSXVNode = VNode | number | boolean | undefined | null;
type FC = (props?: VProps, children?: VNode[], delta?: VDelta) => VElement;
Expand All @@ -24,7 +25,11 @@ const h = (tag: string, props?: VProps, children?: VNode[], delta?: VDelta) => {
props.className = className(<Record<string, boolean>>(<unknown>props.className));
}
if (typeof props?.style === 'object') {
props.style = style(<Record<string, string>>(<unknown>props.style));
const rawStyle = <Record<string, string>>(<unknown>props.style);
const normalizedStyle = Object.keys(rawStyle).some((key) => /[-A-Z]/gim.test(key))
? kebab(rawStyle)
: rawStyle;
props.style = style(<Record<string, string>>normalizedStyle);
}

const vnode = m(tag, props, children, flag, delta);
Expand Down

0 comments on commit 6188a9c

Please sign in to comment.