getndazn / kopytko-framework

A modern Roku's Brightscript framework based on JS world's solutions
MIT License
19 stars 6 forks source link

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

Closed tomek-r closed 2 years ago

tomek-r commented 2 years ago

What did you implement:

Consider such example code

function render() as Object
  if m.top.content = invalid then return invalid

  return [
     {
       name: "Label"
       '....
     },
     {
       name: "Label"
       '....
     }
  ]
end function

When the component is the root and after the next render tick (content is no longer invalid) Kopytko breaks:

Current Function:
063:  sub (elements as Object)
064:      rootElement = m._getRootComponent()
065:  
066:      for each element in elements
067:*       if (element.parentId = Invalid)
068:          parentElement = rootElement.top
069:        else
070:          parentElement = rootElement[element.parentId]
071:        end if
Source Digest(s): 
pkg: dev 1.1.1 f31f77289f1bee3045ec26c97485a566 Kopytko Unit Testing Framework App

Syntax Error. (runtime error &h02) in pkg:/components/renderer/KopytkoDOM.brs(67)

How did you implement it:

When an element is of array type and it is the root component the parent component is one level above it.

How can we verify it:

Run unit tests

Todos:

Is this ready for review?: YES Is it a breaking change?: NO

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 1.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: