MVCoconut / coconut.vdom

Coconut rendering through virtual-dom.
The Unlicense
19 stars 8 forks source link

[diy] Lifecycle event doesn't run when the element rendered conditionally #17

Closed grosmar closed 5 years ago

grosmar commented 5 years ago

Hey,

In DIY branch lifecycle events are not working when the element is rendered with condition:

    function render()
    {
        return 
        model.status == "hello" 
        ? @hxx '<HelloSubView />'
        : @hxx '<button onclick=${model.test()}>setHello</button>';
    }

The HelloSubView will have no lifecycle events, even if they got rendered.

Here is a minimalistic example of the issue: https://github.com/grosmar/coconut-playground/blob/lifecycle-bug/src/HelloView.hx

I know DIY is discontinued but I would prefer to not go back to the master as GEN4 is coming, but that still seems not really finished...

kevinresol commented 5 years ago

Swapping the "root" of render is known to be problematic, you can wrapping it with a div

back2dos commented 5 years ago

I'll close this and make sure it works in gen4 ;)