Skip to content

Commit

Permalink
fix: let jsx accept children arrays
Browse files Browse the repository at this point in the history
React doesn't have special behavior for jsxs currently, and Bun
does not emit calls to jsxs either. This fixes the default jsx
behavior on Bun, at some small unmeasured cost of performance.
  • Loading branch information
Desdaemon committed Jul 22, 2023
1 parent 56370b6 commit 9f97843
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/typed-html/jsx-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ function expandLiterals(props: Record<string, unknown>) {
}
}

export function jsx(tag: any, { children, ...props }: { children: JSX.Element }): JSX.Element {
export function jsx(tag: any, { children, ...props }: { children: JSX.Element | JSX.Element[] }): JSX.Element {
expandLiterals(props);
return createElement(tag, props, sanitizer(children));
const contents = Array.isArray(children) ? children.map(sanitizer) : [sanitizer(children)];
return createElement(tag, props, ...contents);
}

export function jsxs(tag: any, { children, ...props }: { children: JSX.Element[] }): JSX.Element {
Expand Down

0 comments on commit 9f97843

Please sign in to comment.