mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(class): use rawset during instantiation
If classes use a __newindex method it may lead to unexpected behaviour.
This commit is contained in:
@@ -63,17 +63,17 @@ function mixins.new(class, ...)
|
|||||||
if constructor then
|
if constructor then
|
||||||
local parent = class
|
local parent = class
|
||||||
|
|
||||||
function obj:super(...)
|
rawset(obj, 'super', function(self, ...)
|
||||||
parent = getmetatable(parent)
|
parent = getmetatable(parent)
|
||||||
constructor = getConstructor(parent)
|
constructor = getConstructor(parent)
|
||||||
|
|
||||||
if constructor then return constructor(self, ...) end
|
if constructor then return constructor(self, ...) end
|
||||||
end
|
end)
|
||||||
|
|
||||||
constructor(obj, ...)
|
constructor(obj, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
obj.super = nil
|
rawset(obj, 'super', nil)
|
||||||
|
|
||||||
if next(obj.private) then
|
if next(obj.private) then
|
||||||
local private = table.clone(obj.private)
|
local private = table.clone(obj.private)
|
||||||
|
|||||||
Reference in New Issue
Block a user