diff options
author | Aylur <[email protected]> | 2024-07-18 00:38:26 +0200 |
---|---|---|
committer | Aylur <[email protected]> | 2024-07-18 00:38:26 +0200 |
commit | d048f204fd549b6a80f5994380b2f29049095028 (patch) | |
tree | dd488e059b643f0b641a7d8f94564955ca631b2d | |
parent | e5251d23f158c7cc092121c3a7cc0438a73746ec (diff) |
fix(jsx): fat arrow widgets
-rw-r--r-- | gjs/src/jsx/jsx-runtime.ts | 7 |
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) } |