forked from rojo-rbx/rojo
Build tree ancestry correctly (#882)
This commit is contained in:
@@ -163,8 +163,7 @@ function Tree:buildAncestryNodes(previousId: string?, ancestryIds: { string }, p
|
|||||||
-- Build nodes for ancestry by going up the tree
|
-- Build nodes for ancestry by going up the tree
|
||||||
previousId = previousId or "ROOT"
|
previousId = previousId or "ROOT"
|
||||||
|
|
||||||
for i = #ancestryIds, 1, -1 do
|
for _, ancestorId in ancestryIds do
|
||||||
local ancestorId = ancestryIds[i]
|
|
||||||
local value = instanceMap.fromIds[ancestorId] or patch.added[ancestorId]
|
local value = instanceMap.fromIds[ancestorId] or patch.added[ancestorId]
|
||||||
if not value then
|
if not value then
|
||||||
Log.warn("Failed to find ancestor object for " .. ancestorId)
|
Log.warn("Failed to find ancestor object for " .. ancestorId)
|
||||||
@@ -200,7 +199,7 @@ function PatchTree.build(patch, instanceMap, changeListHeaders)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Gather ancestors from existing DOM
|
-- Gather ancestors from existing DOM
|
||||||
local ancestryIds, ancestryIndex = {}, 0
|
local ancestryIds = {}
|
||||||
local parentObject = instance.Parent
|
local parentObject = instance.Parent
|
||||||
local parentId = instanceMap.fromInstances[parentObject]
|
local parentId = instanceMap.fromInstances[parentObject]
|
||||||
local previousId = nil
|
local previousId = nil
|
||||||
@@ -211,8 +210,7 @@ function PatchTree.build(patch, instanceMap, changeListHeaders)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
ancestryIndex += 1
|
table.insert(ancestryIds, 1, parentId)
|
||||||
ancestryIds[ancestryIndex] = parentId
|
|
||||||
knownAncestors[parentId] = true
|
knownAncestors[parentId] = true
|
||||||
parentObject = parentObject.Parent
|
parentObject = parentObject.Parent
|
||||||
parentId = instanceMap.fromInstances[parentObject]
|
parentId = instanceMap.fromInstances[parentObject]
|
||||||
|
|||||||
Reference in New Issue
Block a user