From acc8f403e77c5308694eb4569dccb64a42f6f19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B8=EC=A0=A4=EA=B7=80=20=EA=B3=A0=EC=96=91=EC=9D=B4?= =?UTF-8?q?=EB=93=A4?= <46598063+qwreey75@users.noreply.github.com> Date: Fri, 24 Dec 2021 22:49:30 +0900 Subject: [PATCH] props bug fixed --- src/class.lua | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/class.lua b/src/class.lua index f8583d8..893e439 100644 --- a/src/class.lua +++ b/src/class.lua @@ -53,20 +53,14 @@ function module.init(shared) local func = ClassName.new or ClassName.New or ClassName.__new; if ClassName.__noSetup then -- if is support initing props local childs,props = {},{...}; - local parsed; + local parsed = {}; for iprop = #props,1,-1 do local prop = props[iprop]; - for i,v in ipairs(prop) do - childs[i] = ((iprop == 1) and v or v:Clone()); - prop[i] = nil; - end - if next(prop) then -- there are (key/value)s - if parsed then - for i,v in pairs(prop) do - parsed[i] = v; - end + for i,v in pairs(prop) do + if type(i) == "number" then + childs[i] = ((iprop == 1) and v or v:Clone()); else - parsed = prop; + parsed[i] = v; end end end @@ -166,12 +160,12 @@ function module.init(shared) return function (nprop) nprop = nprop or {}; nprop.Name = lastName; - local item = make(ClassName,nprop); + local item = make(ClassName,nprop,this); addObject(lastName,item); return item; end; elseif propType == "nil" then - return make(ClassName); + return make(ClassName,this); end return make(ClassName,prop,this); end;