Added allowNil to properties
This commit is contained in:
@@ -24,7 +24,7 @@ Container.defineProperty(Container, "childrenEvents", {default = {}, type = "tab
|
|||||||
---@property eventListenerCount table {} The event listener count of the container
|
---@property eventListenerCount table {} The event listener count of the container
|
||||||
Container.defineProperty(Container, "eventListenerCount", {default = {}, type = "table"})
|
Container.defineProperty(Container, "eventListenerCount", {default = {}, type = "table"})
|
||||||
---@property focusedChild table nil The focused child of the container
|
---@property focusedChild table nil The focused child of the container
|
||||||
Container.defineProperty(Container, "focusedChild", {default = nil, type = "table", setter = function(self, value, internal)
|
Container.defineProperty(Container, "focusedChild", {default = nil, type = "table", allowNil=true, setter = function(self, value, internal)
|
||||||
local oldChild = self._values.focusedChild
|
local oldChild = self._values.focusedChild
|
||||||
|
|
||||||
if value == oldChild then return value end
|
if value == oldChild then return value end
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ function PropertySystem.defineProperty(class, name, config)
|
|||||||
canTriggerRender = config.canTriggerRender,
|
canTriggerRender = config.canTriggerRender,
|
||||||
getter = config.getter,
|
getter = config.getter,
|
||||||
setter = config.setter,
|
setter = config.setter,
|
||||||
|
allowNil = config.allowNil,
|
||||||
}
|
}
|
||||||
|
|
||||||
local capitalizedName = name:sub(1,1):upper() .. name:sub(2)
|
local capitalizedName = name:sub(1,1):upper() .. name:sub(2)
|
||||||
@@ -69,8 +70,16 @@ function PropertySystem.defineProperty(class, name, config)
|
|||||||
value = applyHooks(self, name, value, config)
|
value = applyHooks(self, name, value, config)
|
||||||
|
|
||||||
if type(value) ~= "function" then
|
if type(value) ~= "function" then
|
||||||
|
if config.type == "table" then
|
||||||
|
if value == nil then
|
||||||
|
if not config.allowNil then
|
||||||
expect(2, value, config.type)
|
expect(2, value, config.type)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
expect(2, value, config.type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if config.setter then
|
if config.setter then
|
||||||
value = config.setter(self, value, ...)
|
value = config.setter(self, value, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user