Skip to content

Commit 9f97843

Browse files
committed
fix: let jsx accept children arrays
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.
1 parent 56370b6 commit 9f97843

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/typed-html/jsx-runtime.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ function expandLiterals(props: Record<string, unknown>) {
3838
}
3939
}
4040

41-
export function jsx(tag: any, { children, ...props }: { children: JSX.Element }): JSX.Element {
41+
export function jsx(tag: any, { children, ...props }: { children: JSX.Element | JSX.Element[] }): JSX.Element {
4242
expandLiterals(props);
43-
return createElement(tag, props, sanitizer(children));
43+
const contents = Array.isArray(children) ? children.map(sanitizer) : [sanitizer(children)];
44+
return createElement(tag, props, ...contents);
4445
}
4546

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

0 commit comments

Comments
 (0)