diff --git a/components/squad/commons/squad.lua b/components/squad/commons/squad.lua index ff138ec10b8..a52215bc08d 100644 --- a/components/squad/commons/squad.lua +++ b/components/squad/commons/squad.lua @@ -101,7 +101,7 @@ function Squad:row(row) return self end ----@return Html +---@return string function Squad:create() local dataTable = Widget.TableNew{ css = {['margin-bottom'] = '10px'}, diff --git a/components/squad/commons/squad_utils.lua b/components/squad/commons/squad_utils.lua index 2f18e6a085e..dd690f5012f 100644 --- a/components/squad/commons/squad_utils.lua +++ b/components/squad/commons/squad_utils.lua @@ -181,7 +181,7 @@ end ---@param squadClass Squad ---@param personFunction fun(player: table, squadType: integer):WidgetTableRowNew ---@param injector WidgetInjector? ----@return Html +---@return string function SquadUtils.defaultRunManual(frame, squadClass, personFunction, injector) local args = Arguments.getArgs(frame) local injectorInstance = (injector and injector()) or @@ -210,7 +210,7 @@ end ---@param customTitle string? ---@param injector? WidgetInjector ---@param personMapper? fun(person: table): table ----@return Html? +---@return string? function SquadUtils.defaultRunAuto(players, squadType, squadClass, rowCreator, customTitle, injector, personMapper) local args = {type = squadType, title = customTitle} local injectorInstance = (injector and injector()) or diff --git a/components/squad/wikis/dota2/squad_custom.lua b/components/squad/wikis/dota2/squad_custom.lua index c20db55a4d6..2cb2554f6bf 100644 --- a/components/squad/wikis/dota2/squad_custom.lua +++ b/components/squad/wikis/dota2/squad_custom.lua @@ -55,7 +55,7 @@ function ExtendedSquadRow:activeteam() end ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) return SquadUtils.defaultRunManual(frame, Squad, CustomSquad._playerRow, CustomInjector) end diff --git a/components/squad/wikis/overwatch/squad_custom.lua b/components/squad/wikis/overwatch/squad_custom.lua index 1ba4ba70881..2fea3de24c4 100644 --- a/components/squad/wikis/overwatch/squad_custom.lua +++ b/components/squad/wikis/overwatch/squad_custom.lua @@ -48,7 +48,7 @@ function ExtendedSquadRow:number() end ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) local args = Arguments.getArgs(frame) local squad = Squad(args, CustomInjector()):title() @@ -69,7 +69,7 @@ end ---@param playerList table[] ---@param squadType integer ---@param customTitle string? ----@return Html? +---@return string? function CustomSquad.runAuto(playerList, squadType, customTitle) return SquadUtils.defaultRunAuto(playerList, squadType, Squad, SquadUtils.defaultRow(SquadRow), customTitle) end diff --git a/components/squad/wikis/smash/squad_custom.lua b/components/squad/wikis/smash/squad_custom.lua index 4c587b89fc8..552c59d4e7d 100644 --- a/components/squad/wikis/smash/squad_custom.lua +++ b/components/squad/wikis/smash/squad_custom.lua @@ -54,7 +54,7 @@ function ExtendedSquadRow:mains() end ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) local args = Arguments.getArgs(frame) local squad = Squad(args, CustomInjector()):title():header() diff --git a/components/squad/wikis/starcraft/squad_custom.lua b/components/squad/wikis/starcraft/squad_custom.lua index 596488a7182..aa7d2e33e4b 100644 --- a/components/squad/wikis/starcraft/squad_custom.lua +++ b/components/squad/wikis/starcraft/squad_custom.lua @@ -59,7 +59,7 @@ function ExtendedSquadRow:elo() end ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) local args = Arguments.getArgs(frame) local tlpd = Logic.readBool(args.tlpd) diff --git a/components/squad/wikis/starcraft2/squad_custom.lua b/components/squad/wikis/starcraft2/squad_custom.lua index 7659410be8e..048db1bcab1 100644 --- a/components/squad/wikis/starcraft2/squad_custom.lua +++ b/components/squad/wikis/starcraft2/squad_custom.lua @@ -18,7 +18,7 @@ local SquadUtils = Lua.import('Module:Squad/Utils') local CustomSquad = {} ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) return SquadUtils.defaultRunManual(frame, Squad, CustomSquad._playerRow) end @@ -26,7 +26,7 @@ end ---@param playerList table[] ---@param squadType integer ---@param customTitle string? ----@return Html? +---@return string? function CustomSquad.runAuto(playerList, squadType, customTitle) return SquadUtils.defaultRunAuto( playerList, diff --git a/components/squad/wikis/stormgate/squad_custom.lua b/components/squad/wikis/stormgate/squad_custom.lua index e0de2461311..44337dfe8ef 100644 --- a/components/squad/wikis/stormgate/squad_custom.lua +++ b/components/squad/wikis/stormgate/squad_custom.lua @@ -17,7 +17,7 @@ local SquadUtils = Lua.import('Module:Squad/Utils') local CustomSquad = {} ---@param frame Frame ----@return Html +---@return string function CustomSquad.run(frame) return SquadUtils.defaultRunManual(frame, Squad, CustomSquad._playerRow) end @@ -25,7 +25,7 @@ end ---@param playerList table[] ---@param squadType integer ---@param customTitle string? ----@return Html? +---@return string? function CustomSquad.runAuto(playerList, squadType, customTitle) return SquadUtils.defaultRunAuto( playerList, diff --git a/components/widget/widget_factory.lua b/components/widget/widget_factory.lua index 807275fcf8d..bf5074b64dc 100644 --- a/components/widget/widget_factory.lua +++ b/components/widget/widget_factory.lua @@ -14,25 +14,21 @@ local WidgetFactory = Class.new() ---@param widget Widget ---@param injector WidgetInjector? ----@return Html +---@return string function WidgetFactory.work(widget, injector) local children = widget:tryMake(injector) if not children then - return mw.html.create() + return '' end - 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 + if type(children) == 'string' then + return children end - ---@cast children Html - return children + return table.concat(Array.map(children, function(child) + return WidgetFactory.work(child, injector) + end)) end return WidgetFactory