diff options
-rw-r--r-- | core/gjs/src/astalify.ts | 26 | ||||
-rw-r--r-- | core/lua/astal/widget.lua | 8 |
2 files changed, 17 insertions, 17 deletions
diff --git a/core/gjs/src/astalify.ts b/core/gjs/src/astalify.ts index 29e7a5f..c4cbc5c 100644 --- a/core/gjs/src/astalify.ts +++ b/core/gjs/src/astalify.ts @@ -182,19 +182,6 @@ export default function astalify< return acc }, []) - // setup bindings handlers - for (const [prop, binding] of bindings) { - if (prop === "child" || prop === "children") { - this.connect("destroy", binding.subscribe((v: any) => { - this._setChildren(v) - })) - } - this.connect("destroy", binding.subscribe((v: any) => { - setProp(this, prop, v) - })) - setProp(this, prop, binding.get()) - } - // set children const mergedChildren = mergeBindings(children.flat(Infinity)) if (mergedChildren instanceof Binding) { @@ -220,6 +207,19 @@ export default function astalify< } } + // setup bindings handlers + for (const [prop, binding] of bindings) { + if (prop === "child" || prop === "children") { + this.connect("destroy", binding.subscribe((v: any) => { + this._setChildren(v) + })) + } + this.connect("destroy", binding.subscribe((v: any) => { + setProp(this, prop, v) + })) + setProp(this, prop, binding.get()) + } + Object.assign(this, props) setup?.(this) } diff --git a/core/lua/astal/widget.lua b/core/lua/astal/widget.lua index 73fe3b6..8f49409 100644 --- a/core/lua/astal/widget.lua +++ b/core/lua/astal/widget.lua @@ -206,10 +206,6 @@ local function astalify(ctor) -- construct, attach bindings, add children local widget = ctor() - for prop, value in pairs(props) do - widget[prop] = value - end - if getmetatable(children) == Binding then set_children(widget, children:get()) widget.on_destroy = children:subscribe(function(v) @@ -227,6 +223,10 @@ local function astalify(ctor) end) end + for prop, value in pairs(props) do + widget[prop] = value + end + if type(setup) == "function" then setup(widget) end |