Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: allow to render array of elements in root component #30

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/renderer/KopytkoDOM.brs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function KopytkoDOM() as Object
rootElement = m._getRootComponent()

for each element in elements
if (element.parentId = Invalid)
if (Type(element) = "roArray" OR element.parentId = Invalid)
parentElement = rootElement.top
else
parentElement = rootElement[element.parentId]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,34 @@ function TestSuite__KopytkoDOM_updateDOM()
return ts.assertEqual(renderedElement.id, "root", "The element marked to be rendered was not rendered")
end function)

ts.addTest("it renders an array of elements", function (ts as Object) as String
' Given
vNodes = [
{
name: "LayoutGroup",
props: { id: "child1" },
},
{
name: "LayoutGroup",
props: { id: "child2" },
}
]

diffResult = {
elementsToRender: [vNodes],
elementsToRemove: [],
elementsToUpdate: {},
}

' When
ts.kopytkoDOM.updateDOM(diffResult)

' Then
childCount = m.top.getChildCount()

return ts.assertEqual(childCount, vNodes.count(), "The elements marked to be rendered were not rendered")
end function)

ts.addTest("it removes the elements marked to be removed", function (ts as Object) as String
' Given
ts.kopytkoDOM.renderElement({
Expand Down