mirror of
https://github.com/zoriya/astal.git
synced 2026-06-02 02:05:09 +00:00
fix(jsx): fat arrow widgets
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user