getndazn / kopytko-framework

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

fix: not using findNode when removing component's children #37

Closed RadoslawZambrowski closed 1 year ago

RadoslawZambrowski commented 1 year ago

What did you implement:

There is an issue with the renderer that removes the component from its parent when the child of the component has the same id and has been conditionally removed.

How did you implement it:

To fix the issue a map of the rendered elements was introduced and instead of using the native findNode function the map is checked for the existence of the element. findNode includes also the component on which we call it, not only children of it:

From the docs:

Returns the node that is a descendant of the nearest component ancestor of the subject node (possibly the subject node itself) and whose id field is set to name.

How can we verify it:

All should work as before (no regression), but additionally, it should be possible to have the same id for the parent and child components.

E.g Template 1:

return {
    name: "Component1"
    props: { id: "comp1" }
}

Template 2 of Component1:

if condition
    return {
        name: "Component2"
        props: { id: "comp1" }
    }
end if

return invalid

Todos:

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

github-actions[bot] commented 1 year ago

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

The release is available on:

Your semantic-release bot :package::rocket: