Fix child iterator
This commit is contained in:
parent
655ac6f4b2
commit
705ad20481
@ -6,13 +6,14 @@ local Children = Prop:new{ defaultState = {}, uid = "CHILDREN" }
|
|||||||
function Children:with(elementType)
|
function Children:with(elementType)
|
||||||
local propSelf = self
|
local propSelf = self
|
||||||
function elementType:_iterateChildren(opts)
|
function elementType:_iterateChildren(opts)
|
||||||
local func, tbl, start = ipairs(propSelf:getState(self))
|
local tbl = propSelf:with(self)
|
||||||
|
local start, finish = ((opts and opts.from) or 1) - 1, (opts and opts.to) or #tbl
|
||||||
return function(t, i)
|
return function(t, i)
|
||||||
if i == (opts and opts.to) then
|
if i > finish then
|
||||||
return nil, nil
|
return nil, nil
|
||||||
end
|
end
|
||||||
return func(t, i)
|
return i + 1, t[i + 1]
|
||||||
end, tbl, (opts and opts.from) or start
|
end, tbl, start
|
||||||
end
|
end
|
||||||
|
|
||||||
function elementType:childCount()
|
function elementType:childCount()
|
||||||
@ -20,7 +21,7 @@ function Children:with(elementType)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function elementType:_childAt(index)
|
function elementType:_childAt(index)
|
||||||
return propSelf:getState()[elementType:_validChildIndex(index)]
|
return propSelf:getState(self)[elementType:_validChildIndex(index)]
|
||||||
end
|
end
|
||||||
|
|
||||||
function elementType:_validChildIndex(from)
|
function elementType:_validChildIndex(from)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user