From d048f204fd549b6a80f5994380b2f29049095028 Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 18 Jul 2024 00:38:26 +0200 Subject: fix(jsx): fat arrow widgets --- gjs/src/jsx/jsx-runtime.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gjs/src') 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) } -- cgit v1.2.3