It may cause taint, you don't need to replace the frame's meta, it is better to creating a wrapper of the frame like :
Lua Code:
local metaF = {
__index = {
foo = function() print("bar") end
},
}
function BuildFrame(...)
local f = CreateFrame("Frame", ...)
-- Only create the meta once
if not metaF.Inited then
metaF.Inited = true
for k, v in pairs(getmetatable(f).__index) do
if not metaF.__index[k] then
metaF.__index[k] = v
end
end
end
-- Create the wrapper
local w = setmetatable({}, metaF)
w[0] = f[0] -- Copy the userdata, make sure the widget API can works well with the wrapper
-- w.RealUI = f -- You may add a ref to the real frame
return w
end
-- Now you can use it without taint
local frm = BuildFrame()
frm:SetBackdropColor(0,0.5,1)