summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gjs/src/jsx/jsx-runtime.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/gjs/src/jsx/jsx-runtime.ts b/gjs/src/jsx/jsx-runtime.ts
index bb6f4f3..baa0444 100644
--- a/gjs/src/jsx/jsx-runtime.ts
+++ b/gjs/src/jsx/jsx-runtime.ts
@@ -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)
}