Module:FrameTools

-- Frame methods are protected by a `checkSelf` function, which makes them more -- difficult to copy.

local function cloneFrame(frame) local clone = mw.clone(frame)

-- Point methods on `clone` to their `frame` counterparts for methodName, method in pairs(frame) do       if type(method) == "function" and methodName ~= "getParent" then clone[methodName] = function (clone, ...) return method(frame, ...) end end end

-- This method needs special treatment function clone:getParent local parent = frame:getParent

if parent then return cloneFrame(parent) end end

return clone end

-- Creates a frame-like object, with all Devmodule-exclusive arguments removed.

local function makePseudoFrame(frame) local pseudoFrame = cloneFrame(frame) local args = pseudoFrame.args local metatable = getmetatable(args)

-- disable arg caching metatable.__index = nil metatable.__pairs = nil

-- remove args args["#modulename"] = nil args["#mod"] = nil args["#fname"] = nil args["#fun"] = nil

return pseudoFrame end