fix(jsx): fat arrow widgets

This commit is contained in:
Aylur
2024-07-18 00:38:26 +02:00
parent e5251d23f1
commit d048f204fd
+7
View File
@@ -1,6 +1,10 @@
import { Gtk } from "../imports.js"
import * as Widget from "../widgets.js"
function isArrowFunction(func: any): func is (args: any) => any {
return !Object.hasOwn(func, "prototype")
}
export function jsx(
ctor: keyof typeof ctors | typeof Gtk.Widget,
{ children, ...props }: any,
@@ -20,6 +24,9 @@ export function jsx(
else if (children.length > 1)
props.children = children
if (isArrowFunction(ctor))
return ctor(props)
return new ctor(props)
}