Skip to content

Commit

Permalink
fix(jsx): jsx and React.createElement compat function
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Oct 21, 2021
1 parent 7b4f63a commit 79b817a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ const normalize = (jsxVNode: JSXVNode): VNode | VNode[] | undefined => {
}
};

const jsx = (tag: string | FC, props?: VProps, ...children: JSXVNode[]): VNode => {
const jsx = (
tag: string | FC,
props?: VProps,
key?: string | null,
...children: JSXVNode[]
): VNode => {
let delta: VDelta | undefined;
if (props) {
const rawDelta = <VDelta>(<unknown>props.delta);
Expand All @@ -95,6 +100,7 @@ const jsx = (tag: string | FC, props?: VProps, ...children: JSXVNode[]): VNode =
children = <VNode[]>(<unknown>props.children);
delete props.children;
}
if (key) props.key = key;
}
if (typeof tag === 'function') {
return tag(props, <VNode[]>children, delta);
Expand Down

2 comments on commit 79b817a

@rk
Copy link

@rk rk commented on 79b817a Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potential issue from my testing: children isn't guaranteed to be an array, there are cases where it's a singular string or VNode. When the h function is called on line 108, the arguments I'm seeing are: h('td', {key: 'r2c1'}, '10/20/21, 3:17:50 PM', undefined)

@aidenybai
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 4d288cf

Please sign in to comment.