From 941ae157efe4cf700082ee2791f31c7813e9fb59 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Wed, 11 Sep 2024 15:44:46 +0200 Subject: [PATCH] reorder --- components/widget/widget_factory.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/components/widget/widget_factory.lua b/components/widget/widget_factory.lua index 3f8f4e39df4..807275fcf8d 100644 --- a/components/widget/widget_factory.lua +++ b/components/widget/widget_factory.lua @@ -17,20 +17,22 @@ local WidgetFactory = Class.new() ---@return Html function WidgetFactory.work(widget, injector) local children = widget:tryMake(injector) + if not children then return mw.html.create() end - if not Array.isArray(children) then - ---@cast children Html - return children + + if Array.isArray(children) then + ---@cast children Widget[] + local wrapper = mw.html.create() + Array.forEach(children, function(child) + wrapper:node(WidgetFactory.work(child, injector)) + end) + return wrapper end - ---@cast children Widget[] - local wrapper = mw.html.create() - Array.forEach(children, function(child) - wrapper:node(WidgetFactory.work(child, injector)) - end) - return wrapper + ---@cast children Html + return children end return WidgetFactory