Skip to content

Commit

Permalink
reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Sep 11, 2024
1 parent de05092 commit 941ae15
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions components/widget/widget_factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 941ae15

Please sign in to comment.