fix: fix indexing error

This commit is contained in:
Qwreey 2023-01-13 00:01:43 +09:00
parent d10936a57e
commit a181e93ff2

View file

@ -93,6 +93,15 @@ function module.init(shared)
end end
end end
local function rawGetProperty(item,index)
return item[index];
end
local function pcallGetProperty(item,index)
local ok,err = pcall(rawGetProperty,index);
if ok then return err; end
return nil;
end
local function processQuadProperty(processedProperty,iprop,holder,item,className,index,value) local function processQuadProperty(processedProperty,iprop,holder,item,className,index,value)
if processedProperty[index] then return; end if processedProperty[index] then return; end
@ -100,7 +109,7 @@ function module.init(shared)
local indexType = typeof(index); local indexType = typeof(index);
-- child -- child
if indexType == "string" and valueType == "table" and value.__type == "quad_register" then -- register (bind to store event) if indexType == "string" and valueType == "table" and pcallGetProperty(value,"__type") == "quad_register" then -- register (bind to store event)
processedProperty[index] = true; -- ignore next processedProperty[index] = true; -- ignore next
-- store reading -- store reading
do do
@ -146,13 +155,13 @@ function module.init(shared)
processedProperty[index] = true; -- ignore next processedProperty[index] = true; -- ignore next
-- prop set -- prop set
setProperty(item,index,value,className); setProperty(item,index,value,className);
elseif indexType == "number" and valueType == "table" and value.__type == "quad_style" then -- style elseif indexType == "number" and valueType == "table" and pcallGetProperty(value,"__type") == "quad_style" then -- style
-- style parsing -- style parsing
for _,thisStyle in ipairs(parseStyles(value)) do for _,thisStyle in ipairs(parseStyles(value)) do
if not processedProperty[thisStyle] then if not processedProperty[thisStyle] then
processedProperty[thisStyle] = true; processedProperty[thisStyle] = true;
for styleIndex,styleValue in pairs(thisStyle) do for styleIndex,styleValue in pairs(thisStyle) do
if type(styleValue) ~= "table" or styleValue.__type ~= "quad_style" then if type(styleValue) ~= "table" or pcall(styleValue,"__type") ~= "quad_style" then
processQuadProperty(processedProperty,iprop,holder,item,className,styleIndex,styleValue); processQuadProperty(processedProperty,iprop,holder,item,className,styleIndex,styleValue);
end end
end end